Welcome to an engaging lesson on slice 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 slices. Our goal on this exciting journey is to assist Gloria through her escapade and identify the maximum value she encounters along the way. Are you ready to embark on this adventure?
Gloria's quest unfolds with two slices, both full of non-negative integers. Starting at the first element of sliceA
, she leaps to sliceB
based on the index she discovers in sliceA
. She then bounces back to sliceA
according to the index she stumbles upon in sliceB
. Gloria repeats these hops until she returns to where she started in sliceA
. What an adventure!
Your challenge is to craft a Go function that aids Gloria on her trip. The function will take two slices of integers as inputs, representing sliceA
and sliceB
. The objective is to find the highest value from sliceB
that Gloria jumps to during her voyage.
It is guaranteed that at some point, Gloria returns to the starting position.
