L3 Onsite
Anonymous User
2183

Had round 2 today, got really nervous and messed up.

Actual description was very long. Tldr - Was given this question - You have n teleport pads labeled 0 to n-1, with nums[i] telling where pad i sends you.

Arrange the pads in a circle (perm) so that the total jump cost
|perm[0] - nums[perm[1]]| + |perm[1] - nums[perm[2]]| + ... + |perm[n-1] - nums[perm[0]]|

is minimized. If there's a tie, return the lexicographically smallest

Expected TC - nlogn

I found the difficulty harder that what I seen previously, what do you guys think.

Location - Zurich
Interviewer from US

Comments (11)