To the Top
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

Subscribe to Feed Burner | 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.


def is_shifted(a, b):
# Fill this in.

print is_shifted('abcde', 'cdeab')
# True
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 879 Views, 25491 Search Bots | 79 Words Subscribe to Feed Burner

Related Articles

  1. Algorithm Interview: Permutations of numbers
  2. Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
  3. Daily Interview Problem: Reverse Words in a String
  4. Spreadsheet Column Title
  5. Algorithm Interview Question: Symmetric k-ary Tree
  6. Sorting a list with 3 unique numbers
  7. Daily Interview Problem: Word Ordering in a Different Alphabetical Order
  8. Daily Interview Question: Edit Distance
  9. Most Frequent Subtree Sum
  10. Algorithm Interview: Determine If Linked List is Palindrome

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />