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, 19576 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, 19576 Search Bots | 98 Words Subscribe to Feed Burner

Related Articles

  1. [Daily Problem] Move Zeros
  2. Daily Interview Problem: Minimum Removals for Valid Parenthesis
  3. Daily Interview Problem: Full Binary Tree
  4. Plus One
  5. Algorithm Interview: Longest Consecutive Sequence
  6. Autorun.inf Virus Protection
  7. Daily Interview Problem: First Missing Positive Integer
  8. Spreadsheet Column Title
  9. Daily Interview Question: Longest Sequence with Two Unique Numbers
  10. Sort a Partially Sorted List

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