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 | 880 Views, 20191 Search Bots | 86 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 880 Views, 20191 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 | 880 Views, 20191 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
- Patterns for breaking down questions you haven
- Algorithm Interview: String Compression
- Print a tree level-by-level, with line-breaks
- Spreadsheet Column Title
- Algorithm Interview: Shifted String
- Algorithm Interview Question: Symmetric k-ary Tree
- Daily Interview Question: Create a Simple Calculator
- Design Tic-Tac-Toe
- Daily Interview Problem: Arithmetic Binary Tree
- Longest Substring Without Repeating Characters
©2006~2024 SteakOverCooked - 0.00938 Seconds(s) - 2099.25 KB/s - 32 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 !