File: root - text - article - 2019 - 12 - decode-string.txt.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 785 Views, 20745 Search Bots | 67 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 785 Views, 20745 Search Bots | 67 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by Google:
Given a string with a certain rule: k[string] should be expanded to string k times. So for example, 3[abc] should be expanded to abcabcabc. Nested expansions can happen, so 2[a2[b]c] should be expanded to abbcabbc.
Your starting point:
def decodeString(s):
# Fill this in.
print decodeString('2[a2[b]c]')
# abbcabbc
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 785 Views, 20745 Search Bots | 67 Words Given a string with a certain rule: k[string] should be expanded to string k times. So for example, 3[abc] should be expanded to abcabcabc. Nested expansions can happen, so 2[a2[b]c] should be expanded to abbcabbc.
Your starting point:
def decodeString(s):
# Fill this in.
print decodeString('2[a2[b]c]')
# abbcabbc
Related Articles
- [Daily Problem] Longest Increasing Subsequence
- Fix Brackets
- Algorithm Interview: Smallest Number that is not a Sum of a Subset of List
- Find Pythagorean Triplets
- Fibonacci coding
- Daily Interview Problem: Word Ordering in a Different Alphabetical Order
- Non-decreasing Array with Single Modification
- Detect Linked List Cycle
- Daily Interview Problem: Reconstrunct Binary Tree from Preorder and Inorder Traversals
- Daily Interview Problem: Spiral Traversal of Grid
©2006~2024 SteakOverCooked - 0.02064 Seconds(s) - 952.761 KB/s - 30 Online Memory: 492.02 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 !