FastPrepRotation with at Most Three Mismatches
Problems/Rotation with at Most Three Mismatches

Rotation with at Most Three Mismatches

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes two strings, cyclic rotation, and an allowance of three mismatches. We supplied how to combine the rotation with the mismatch count, how to treat equal lengths, and a function signature. Our version is about 89% the same as the reported question.

Return whether second can be cyclically rotated so that it differs from first at no more than three positions.

The strings must have equal length. A rotation by zero positions is allowed.

Function

similarAfterRotation(first: String, second: String) → boolean

Examples

Example 1

first = "abcde"second = "cdeab"return = true

A cyclic shift produces an exact match.

Example 2

first = "abcdef"second = "xbcyez"return = true

The zero rotation differs at exactly three positions.

Constraints

  • 0 <= first.length, second.length <= 2000
  • The strings contain lowercase English letters.

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024

Similar questions at other companies

  • Reliable LLM Call with Independent Retry BudgetsStripe · OAStripe interview questions
  • Tennis Game ScoreAbridge · OAAbridge interview questions
  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Robot Assembly Line ConflictsGoogle · OAGoogle interview questions
  • Parcel Event TrackingAirbnb · OAAirbnb interview questions
  • Repair One Movement InstructionOpenAI · OAOpenAI interview questions
  • Count Straight-Line Word Occurrences in a GridOptiver · OAOptiver interview questions
  • Format TextTikTok · OATikTok interview questions
  • Binary String Swap TimeMicrosoft · OAMicrosoft interview questions
  • Communications HandlerAkuna Capital · OAAkuna Capital interview questions
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public boolean similarAfterRotation(String first, String second) {
        // Write your code here.
    }

}
Checking account…