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 | 625 Views, 21702 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 | 625 Views, 21702 Search Bots | 79 Words Subscribe to Feed Burner

Related Articles

  1. Fibonacci coding
  2. New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
  3. Daily Interview Problem: Distribute Bonuses
  4. Algorithm Interview: Level Order Traversal of Binary Tree
  5. Daily Interview Puzzle: Ways to Traverse a Grid
  6. Daily Interview Problem: Reconstrunct Binary Tree from Preorder and Inorder Traversals
  7. Algorithm Interview Question: Find the Single Element in an Array of Duplicates
  8. Algorithm Interview: Make the Largest Number
  9. Daily Interview Problem: Min Range Needed to Sort
  10. Algorithm Interview: Smallest Number that is not a Sum of a Subset of List

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" />