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 | 621 Views, 16222 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 | 621 Views, 16222 Search Bots | 86 Words Subscribe to Feed Burner

Related Articles

  1. Sorting a list with 3 unique numbers
  2. PHP Unit Tests on VPS Server
  3. Algorithm Interview: Maximum Path Sum in Binary Tree
  4. New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
  5. Daily Interview Problem: Given two arrays, write a function to compute their intersection.
  6. Daily Interview Problem: Reverse Words in a String
  7. Daily Interview Problem: Circle of Chained Words
  8. Daily Interview Problem: Largest Product of 3 Elements I
  9. Daily Interview Problem: Validate Binary Search Tree
  10. [Daily Problem] Add two numbers as a linked list

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="index, follow">