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

Related Articles

  1. Algorithm Interview: Convert Roman Numerals to Decimal
  2. Daily Interview Problem: Longest Substring With K Distinct Characters
  3. Binary Tree Level with Minimum Sum
  4. Algorithm Interview: Subarray With Target Sum
  5. Windows Scripting
  6. Absolute Path
  7. Algorithm Interview: No Adjacent Repeating Characters
  8. Daily Interview Problem: Buddy Strings
  9. Daily Interview Problem: First Missing Positive Integer
  10. Daily Interview Problem: Circle of Chained Words

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="noindex, follow" />