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 | 496 Views, 26448 Search Bots | 98 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 496 Views, 26448 Search Bots | 98 Words
| 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:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 496 Views, 26448 Search Bots | 98 Words 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']
Related Articles
- Daily Interview Problem: Queue Using Two Stacks
- Fix Brackets
- Sorting a list with 3 unique numbers
- Algorithm Interview: Determine If Linked List is Palindrome
- [Daily Problem] Witness of The Tall People
- PHP Unit Tests on VPS Server
- How to Play WAV music under DOS?
- Find Pythagorean Triplets
- [Daily Problem] Remove k-th Last Element From Linked List
- Daily Interview Problem: Deepest Node in a Binary Tree
©2006~2024 SteakOverCooked - 0.00726 Seconds(s) - 2636.262 KB/s - 39 Online Memory: 491.46 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !