Can You Jump to the Last Index
Updated
Problem statement
You stand on index 0 of the array nums. From index i you may jump forward by any whole number of steps from 1 up to nums[i]. A value of 0 means you cannot move on from that index.
Return true if some sequence of jumps lands on the last index, and false otherwise. The value stored at the last index does not matter, and with only one element you are already there.
Function
canReachLast(nums: int[]) → booleanExamples
Example 1
nums = [1,3,0,0,2,0]return = trueFrom index 0 jump 1 step to index 1. Its value 3 lets you jump to index 4, past both zeros. From index 4 one step reaches index 5, the last index.
Example 2
nums = [2,0,1,0,3]return = falseFrom index 0 you can reach index 1 or 2. Index 1 holds 0, and index 2 holds 1, which only reaches index 3. Index 3 holds 0, so no path gets past it to index 4.
Example 3
nums = [0]return = trueThe array has one element, so you start on the last index. No jump is needed.
Constraints
1 <= nums.length <= 10^40 <= nums[i] <= 10^4
More Adobe Phone Screen questions
- Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
- All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
- Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
- Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
- Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
- Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
- Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026
Similar questions at other companies
- Jump GamePaytm · PHONE SCREENPaytm interview questions
- Minimum Cost for a Target WeightPace Stock Broking Services · PHONE SCREEN
- Jump Game IINavi · PHONE SCREEN
- Best Stock Profit With a Sell FeeKaseya · PHONE SCREEN
- Return a Minimum-Coin Change BreakdownDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
- Most Relevant Text SpanHebbia · PHONE SCREEN
- Fewest Jumps to the End of an ArrayRippling · PHONE SCREENRippling interview questions
- Split Array to Minimize the Largest SumNation with NaMo · PHONE SCREEN
- Best Time to Buy and Sell StockOracle · PHONE SCREEN · ONSITE INTERVIEWOracle interview questions
- Best Time to Buy and Sell StockJP Morgan Chase · PHONE SCREENJP Morgan Chase interview questions
Interview reports that mention this question
Adobe interview experiences
- Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
- Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
- Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
- Adobe New Grad MTS Interview Questions: 7 Experiences
- Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)