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

Related Articles

  1. Kaprekar
  2. Two-Sum
  3. CPU Utilization
  4. Daily Interview Problem: Product of Array Except Self
  5. Spreadsheet Column Title
  6. Number of Ways to Climb Stairs
  7. Linode Support Ticket 10029540 - Other - Important Notice Regarding Ubuntu 17.10 Image
  8. Daily Interview Puzzle: Falling Dominoes
  9. Algorithm Interview: Smallest Number that is not a Sum of a Subset of List
  10. Daily Interview Question: Longest Sequence with Two Unique Numbers

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