File: root - text - article - 2019 - 12 - jump-to-the-end.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 879 Views, 20181 Search Bots | 86 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 879 Views, 20181 Search Bots | 86 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by Facebook:
Starting at index 0, for an element n at index i, you are allowed to jump at most n indexes ahead. Given a list of numbers, find the minimum number of jumps to reach the end of the list.
Example:
Input: [3, 2, 5, 1, 1, 9, 3, 4]
Output: 2
Explanation:
The minimum number of jumps to get to the end of the list is 2:
3 - 5 - 4
Here's a starting point:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 879 Views, 20181 Search Bots | 86 Words Starting at index 0, for an element n at index i, you are allowed to jump at most n indexes ahead. Given a list of numbers, find the minimum number of jumps to reach the end of the list.
Example:
Input: [3, 2, 5, 1, 1, 9, 3, 4]
Output: 2
Explanation:
The minimum number of jumps to get to the end of the list is 2:
3 - 5 - 4
Here's a starting point:
def jumpToEnd(nums):
# Fill this in.
print jumpToEnd([3, 2, 5, 1, 1, 9, 3, 4])
# 2
Related Articles
- Algorithm Interview Question: Nth Fibonacci Number
- [Daily Problem] Validate Balanced Parentheses
- Daily Interview Problem: Deepest Node in a Binary Tree
- Invert a Binary Tree
- Daily Interview Problem: Largest BST in a Binary Tree
- Plus One
- Algorithm Interview: Permutations of numbers
- Daily Interview Problem: Min Range Needed to Sort
- Autorun.inf Virus Protection
- Daily Interview Problem: Largest Product of 3 Elements I
©2006~2024 SteakOverCooked - 0.00811 Seconds(s) - 2252.476 KB/s - 31 Online Memory: 491.58 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !