FastPrepSorted Cyclic Shift Difference Sums
Problems/Sorted Cyclic Shift Difference Sums

Sorted Cyclic Shift Difference Sums

Capital One logoCapital One● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report gives two arrays of the same length, every cyclic shift, sums of absolute differences, and sorted output. We chose the shift direction (right), the number limits, 64-bit totals, and the function signature.

Given two integer arrays nums1 and nums2 of equal length, consider every cyclic right shift of nums1. For shift s, the value aligned with index i is nums1[(i - s + n) % n].

For every shift, compute the sum of absolute differences between aligned values from the shifted nums1 and nums2. Return all n sums sorted in nondecreasing order.

Function

sortedCyclicShiftDifferences(nums1: int[], nums2: int[]) → long[]

Examples

Example 1

nums1 = [1,2,3]nums2 = [2,1,3]return = [2,2,4]

The right shifts are [1,2,3], [3,1,2], and [2,3,1], with difference sums 2, 2, and 4.

Example 2

nums1 = [5]nums2 = [-2]return = [7]

A one-element array has only one cyclic shift.

Example 3

nums1 = [0,10]nums2 = [10,0]return = [0,20]

The unshifted alignment costs 20, while shifting right once makes the arrays equal.

Constraints

  • 1 <= nums1.length = nums2.length <= 500.
  • -10^9 <= nums1[i], nums2[i] <= 10^9.
  • Use 64-bit arithmetic for every sum.

More Capital One Online Assessment questions

  • Rank Football TeamsOA · Seen Oct 2026
  • Count Subarrays Matching a Comparison PatternOA · Seen Oct 2026
  • Arithmetic Triplets After QueriesOA · Seen Oct 2026
  • Branch with the Most FilesOA · Seen Oct 2026
  • Count One-Swap Number PairsOA · Seen Oct 2026
  • Distinct Values on Maximum-Sum FramesOA · Seen Oct 2026
  • Earliest Meeting Time for All EmployeesOA · Seen Oct 2026
  • Earn the Most 🐝OA · Seen Oct 2026
  • Sort Adjacent PairsOA · Seen Oct 2026
  • Bouncing Diagonal WeightsOA · Seen Oct 2026

Similar questions at other companies

  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Minimize Task Resource ConsumptionNVIDIA · OANVIDIA interview questions
  • Macaron Order PriceOpenAI · OAOpenAI interview questions
  • Optimize Package Order by Sorting One WindowAmazon · OA
  • Track Received Byte RangesRoblox · OARoblox interview questions
  • Sorted Absolute-Difference Sums Across Cyclic ShiftsByteDance · OAByteDance interview questions
  • Signal PingsVisa · OAVisa interview questions
  • Aggregate Paginated Project Run RecordsReplit · OA
  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Parcel Attribute Store with TTLAirbnb · OAAirbnb interview questions

Interview reports that mention this question

  • Capital One Experienced Engineer Power Day and OA: 6 Experiences

Capital One interview experiences

  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
  • Capital One TDP Agentic Power Day: 25 Experiences (Part 1 of 2)
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public long[] sortedCyclicShiftDifferences(int[] nums1, int[] nums2) {
        // Write your code here.
    }
}
Checking account…