To the Top
File:  root - text - article - 2019 - 12 - merge-list-of-number-into-ranges.txt.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 186 Views, 19481 Search Bots | 98 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by Facebook:

Given a sorted list of numbers, return a list of strings that represent all of the consecutive numbers.

Example:
Input: [0, 1, 2, 5, 7, 8, 9, 9, 10, 11, 15]
Output: ['0->2', '5->5', '7->11', '15->15']
Assume that all numbers will be greater than or equal to 0, and each element can repeat.

Here is a starting point:


def findRanges(nums):
# Fill this in.

print findRanges([0, 1, 2, 5, 7, 8, 9, 9, 10, 11, 15])
# ['0->2', '5->5', '7->11', '15->15']
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 186 Views, 19481 Search Bots | 98 Words Subscribe to Feed Burner

Related Articles

  1. [Daily Problem] Angles of a Clock
  2. Algorithm Interview Question: H-Index
  3. Daily Interview Puzzle: Ways to Traverse a Grid
  4. Windows Scripting
  5. First and Last Indices of an Element in a Sorted Array
  6. Daily Interview Puzzle: Falling Dominoes
  7. Maximum In A Stack
  8. Find Pythagorean Triplets
  9. Daily Interview Problem: Reconstrunct Binary Tree from Preorder and Inorder Traversals
  10. Patterns for breaking down questions you haven

Comments (0)

    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" />