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 | 857 Views, 24421 Search Bots | 79 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 857 Views, 24421 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 | 857 Views, 24421 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 Question: H-Index
- Batch Programming in XP
- Consecutive Ones
- Daily Interview Problem: Contiguous Subarray with Maximum Sum
- PHP Unit Tests on VPS Server
- Compare Version Numbers
- Algorithm Interview: Permutations of numbers
- Algorithm Interview: Longest Consecutive Sequence
- Daily Interview Problem: Trapping Rainwater
- Daily Interview Puzzle: Minimum Size Subarray Sum
©2006~2024 SteakOverCooked - 0.00688 Seconds(s) - 2873.62 KB/s - 36 Online Memory: 492.6 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="index, 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 !