FastPrepMinimum Difference Across Cyclic Rotations
Problems/Minimum Difference Across Cyclic Rotations

Minimum Difference Across Cyclic Rotations

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two ZipRecruiter new-grad OA reports describe equal lengths, every cyclic rotation, sums of aligned absolute differences, and the minimum. We supplied limits and a function signature.

You are given equal-length integer arrays first and second. For every cyclic left rotation of first, sum the absolute differences of aligned elements.

Return the minimum sum across all rotations.

Function

minimumRotationDifference(first: int[], second: int[]) → long

Examples

Example 1

first = [1,2,3]second = [2,3,1]return = 0

One left rotation makes the arrays equal.

Example 2

first = [1,4]second = [2,8]return = 5

The unrotated cost is 1 + 4 = 5, which is minimal.

Constraints

  • 1 <= first.length == second.length <= 2000
  • -1000000000 <= value <= 1000000000

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

  • Bank Accounts with Balance HistoryMeta · OAMeta interview questions
  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Repeated Mirror XORMathWorks · OAMathWorks interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Stabilize Student Test ScoresVirtu Financial · OAVirtu Financial interview questions
  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Minimize Task Resource ConsumptionNVIDIA · OANVIDIA interview questions
  • Index of the Maximum After Left RotationsChubb · OAChubb interview questions
  • Leaves Remaining After WindCresta · OACresta interview questions
  • Rolling MetricsAkuna Capital · OAAkuna Capital interview questions

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public long minimumRotationDifference(int[] first, int[] second) {
        // Write your code here.
    }

}
Checking account…