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 | 879 Views, 25491 Search Bots | 79 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 879 Views, 25491 Search Bots | 79 Words
| Browse | Archive
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 | 879 Views, 25491 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
Related Articles
- Algorithm Interview: Permutations of numbers
- Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
- Daily Interview Problem: Reverse Words in a String
- Spreadsheet Column Title
- Algorithm Interview Question: Symmetric k-ary Tree
- Sorting a list with 3 unique numbers
- Daily Interview Problem: Word Ordering in a Different Alphabetical Order
- Daily Interview Question: Edit Distance
- Most Frequent Subtree Sum
- Algorithm Interview: Determine If Linked List is Palindrome
©2006~2024 SteakOverCooked - 0.0071 Seconds(s) - 2700.256 KB/s - 15 Online Memory: 492.98 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 !