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, 20735 Search Bots | 67 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 785 Views, 20735 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, 20735 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
- Reverse a Directed Graph
- Algorithm Interview Question: Symmetric k-ary Tree
- [Daily Problem] Move Zeros
- Progess made
- Algorithm Interview: Longest Consecutive Sequence
- Batch Programming in XP
- Daily Interview Puzzle: Falling Dominoes
- Daily Interview Problem: First Missing Positive Integer
- Floor and Ceiling of a Binary Search Tree
- CPU Utilization
©2006~2024 SteakOverCooked - 0.00809 Seconds(s) - 2426.807 KB/s - 433 Online Memory: 491.68 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 !