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 | 776 Views, 20651 Search Bots | 67 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 776 Views, 20651 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 | 776 Views, 20651 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
- Floor and Ceiling of a Binary Search Tree
- Reverse a Linked List
- Daily Interview Question: Edit Distance
- [Daily Problem] Remove k-th Last Element From Linked List
- Algorithm Interview: Level Order Traversal of Binary Tree
- Find the non-duplicate number
- Palindrome Integers
- Algorithm Interview Question: Nth Fibonacci Number
- Daily Interview Problem: Deepest Node in a Binary Tree
- Daily Interview Problem: Longest Substring With K Distinct Characters
©2006~2024 SteakOverCooked - 0.00767 Seconds(s) - 6979.741 KB/s - 29 Online Memory: 527.45 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 !