File: root - text - article - 2020 - 01 - shifted-string.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 788 Views, 23362 Search Bots | 79 Words
| Browse | Archive
![Subscribe to Feed Burner Subscribe to Feed Burner](/images/form/rss.gif)
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 788 Views, 23362 Search Bots | 79 Words
![Subscribe to Feed Burner Subscribe to Feed Burner](/images/form/rss.gif)
Hi, here's your problem today. This problem was recently asked by Apple:
You are given two strings, A and B. Return whether A can be shifted some number of times to get B.
Eg. A = abcde, B = cdeab should return true because A can be shifted 3 times to the right to get B. A = abc and B= acb should return false.
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 788 Views, 23362 Search Bots | 79 Words You are given two strings, A and B. Return whether A can be shifted some number of times to get B.
Eg. A = abcde, B = cdeab should return true because A can be shifted 3 times to the right to get B. A = abc and B= acb should return false.
def is_shifted(a, b):
# Fill this in.
print is_shifted('abcde', 'cdeab')
# True
![Subscribe to Feed Burner Subscribe to Feed Burner](/images/form/rss.gif)
Related Articles
- Sort a Partially Sorted List
- Algorithm Interview: Smallest Number that is not a Sum of a Subset of List
- Invert a Binary Tree
- ImageMagick Vulnerabilities - CVE-2016–3714
- Algorithm Interview: Lowest Common Ancestor of 2 Nodes in Binary Tree
- Daily Interview Problem: Merge K Sorted Linked Lists
- Daily Interview Problem: Min Stack
- Find Pythagorean Triplets
- Daily Interview Problem: Given two arrays, write a function to compute their intersection.
- Daily Interview Problem: Distribute Bonuses
©2006~2024 SteakOverCooked - 0.0129 Seconds(s) - 1457.159 KB/s - 16 Online
Memory: 492.27 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" />
![](/images/top.jpg)
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !