Back to problems

Sort Cyclic Shift Absolute-Difference Costs

Algorithm · ByteDance · Easy

Cyclic Shift Distances Medium · Topics · Company Tags · Hints You are given two integer arrays a and b of the same length n. For each integer k where 0 <= k < n, create an array by taking the last k elements of a and moving them to the front, preserving their relative order — this is the k‑shifted version of a. Compute the sum of absolute differences between corresponding elements of this shifted array and b: Collect the n sums obtained for all possible values of k and…

Checking your access…