Introduction

Welcome to a delightful lesson on list traversal! Today, we invite you to join an endearing bunny named Gloria on an intricate quest. Gloria has a soft spot for number games, especially when they involve hopping between lists. Our goal on this exciting journey is to assist Gloria with her escapade and identify the maximum value she encounters along the way. Are you ready to embark on this adventure?

Task Statement

Gloria's quest unravels with two lists, both brimming with non-negative integers. Starting at the first element of listA, she leaps to listB based on the index she discovers in listA. She then bounces back to listA according to the index she stumbles upon in listB. Gloria repeats these hops until she returns to where she started in listA. What an adventure!

Your challenge is to craft a C# method that aids Gloria on her trip. The method will take two lists of integers as inputs, representing listA and listB. The objective is to find the highest value from listB that Gloria jumps to during her voyage.

It is guaranteed that at some point Gloria returns to the starting position.

Example

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal