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 | 492 Views, 26438 Search Bots | 98 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 492 Views, 26438 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 | 492 Views, 26438 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
- Algorithm Interview Question: Find the Single Element in an Array of Duplicates
- Daily Interview Problem: Arithmetic Binary Tree
- Patterns for breaking down questions you haven
- Daily Interview Problem: Contiguous Subarray with Maximum Sum
- Spreadsheet Columns
- Find the non-duplicate number
- [Daily Problem] Move Zeros
- Daily Interview Problem: First Missing Positive Integer
- Daily Interview Problem: Group Words that are Anagrams
- Algorithm Interview: Convert Roman Numerals to Decimal
©2006~2024 SteakOverCooked - 0.00745 Seconds(s) - 2632.444 KB/s - 30 Online Memory: 493.2 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="index, 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 !