Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Check String Rotation

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Check String Rotation. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Datavant identity resolution workflows may compare normalized identifier strings received in different segment orders. Given two strings, determine whether the second string is a rotation of the first.

A string b is a rotation of string a if b can be produced by moving a prefix of a to its end. The rotation may move zero characters, so every string is a rotation of itself.

Formal Specification

Implement is_rotation(a, b).

  • Input: Two strings a and b, containing lowercase English letters and digits.
  • Output: Return True if b is a rotation of a; otherwise, return False.

Constraints

  • 0 <= len(a), len(b) <= 10^5
  • Strings contain only lowercase English letters and digits
  • Matching is case-sensitive
  • An empty string is a rotation only of another empty string

Function Signature

def is_rotation(a, b):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output