Zappos | Software Engineer interview question
Anonymous User
464

I came across this problem where given an array of integers, tell if the sequence of integers will exit the array from left, right or deadend. You enter the array from the left and move N indices(where N is the value of the integer) in the specified direction(positive is right, negative is left)

Examples
[1,1,1] -> Exits Right
[1,-2]=> Exits Left
[2,0,-1]-> Deadends
[2,5,1,-2,0]-> Exits Right
One solution which comes to my mind is if value of all integers are positive then Exits Right or Exits Left. However this solution does not cover all the scenario. I need help to solve this problem.

Looking for solution in Java preferably

Comments (3)
No comments yet.