To the Top
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 | 560 Views, 14773 Search Bots | 86 Words

Subscribe to Feed Burner | 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:


def jumpToEnd(nums):
# Fill this in.

print jumpToEnd([3, 2, 5, 1, 1, 9, 3, 4])
# 2
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 560 Views, 14773 Search Bots | 86 Words Subscribe to Feed Burner

Related Articles

  1. Daily Interview Problem: Contiguous Subarray with Maximum Sum
  2. Find Missing Numbers in an Array
  3. Daily Interview Problem: Product of Array Except Self
  4. Daily Interview Problem: Given two arrays, write a function to compute their intersection.
  5. [Daily Problem] Remove k-th Last Element From Linked List
  6. Algorithm Interview: Shifted String
  7. Daily Interview Problem: First Missing Positive Integer
  8. Autorun.inf Virus Protection
  9. Compare Version Numbers
  10. Non-decreasing Array with Single Modification

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />