Reported October 2026
Capital Onesimulation

Sorted Cyclic Shift Difference Sums

Reported by candidates from Capital One's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Capital One OA. Under 2s to a working solution.
Founder's read

Capital One reported this one in October 2026, and the title sounds scarier than it is. You get two arrays, every cyclic right shift of nums1, and a sum of absolute differences per shift, then a sort. The pattern is array simulation with a careful look at the input size. If the OA lands in your inbox this week, read the constraints first. They decide how fancy you need to be. And if you freeze on the live assessment, StealthCoder runs invisibly as a safety net so you still ship a clean answer.

The problem

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.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Look at the constraint: n is at most 500. That means n shifts times n positions is 250,000 operations. Brute force is the intended solution, not a trap. Don't hunt for a convolution or a clever trick. For each shift s, loop i from 0 to n-1, read nums1[(i - s + n) % n], subtract nums2[i], take the absolute value, and add to a 64-bit sum. Collect n sums, sort, return. The real pitfall is overflow. Values reach 10^9 in magnitude, so one difference can hit 2*10^9 and the total can hit 10^12. Use long, not int. The second pitfall is the index formula. Get the modulo wrong and you shift left instead of right, and Example 1 will show it. In the live OA, StealthCoder is the hedge if you blank on the modulo or the types. Check Example 3 by hand before submitting.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Sorted Cyclic Shift Difference Sums cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Capital One's OA.

Capital One reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Sorted Cyclic Shift Difference Sums FAQ

How hard is the Capital One sorted cyclic shift problem really?+

Easy to medium. With n up to 500, a double loop over shifts and positions is fast enough. The difficulty is only in the index math and 64-bit sums. If you code it cleanly, it's a ten-minute problem.

What's the trick to this problem?+

There isn't a deep one. Read the constraint, see that 250,000 operations is tiny, and brute force it. Compute each shift's sum with (i - s + n) % n indexing, store it, then sort the results.

Why does the problem stress 64-bit arithmetic?+

Each value can be up to 10^9 in magnitude, so a single absolute difference can reach 2*10^9, which overflows a 32-bit int. Summed over 500 elements, totals reach about 10^12. Use long in Java or C++, and Python handles it natively.

What edge cases should I test?+

Test n = 1, where there's only one shift. Test identical arrays, where one shift gives zero. Test negative values. Also test Example 3, where shifting right once makes the arrays equal, to confirm your direction is right and not left.

How do I prepare in 48 hours for an OA like this?+

Practice array index math with modulo, especially cyclic shifts and rotations. Get fast at reading constraints to pick brute force versus optimized. Write the shift formula from memory, and double-check overflow types. Then run the examples by hand before you submit.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Capital One.

OA at Capital One?
Invisible during screen share
Get it