You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//This is an implicit bfs solution. i == curEnd means you visited all the items on the current level. Incrementing jumps++ is like incrementing the level you are on. And curEnd = max is like getting the queue size (level size) for the next level you are traversing.
int jumps = 0,
curEnd = 0,
max = 0;
//i < A.length - 1 BECAUSE The last number doesn't need to be traversed. The question just needs to reach to the last number, then it ends and then outputs the result.