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 | 874 Views, 20163 Search Bots | 86 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 874 Views, 20163 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 | 874 Views, 20163 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
- Daily Interview Problem: Find the k-th Largest Element in a List
- Binary Tree Level with Minimum Sum
- Sorting a list with 3 unique numbers
- Algorithm Interview Question: Nth Fibonacci Number
- Daily Interview Problem:Create a balanced binary search tree
- Daily Interview Problem: Arithmetic Binary Tree
- ImageMagick Vulnerabilities - CVE-2016–3714
- Top K Frequent words
- [Daily Problem] Move Zeros
- Daily Interview Problem: Reverse Words in a String
©2006~2024 SteakOverCooked - 0.00719 Seconds(s) - 2586.967 KB/s - 45 Online Memory: 491.73 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 !