Question Details
Problem You are given an array of integers. In each turn you may swap any one pair of adjacent elements. Return the minimum number of turns (swaps) needed to sort the array in non-decreasing order. Follow-ups What is the relationship between minimum adjacent swaps and the number of inversions in the array? How can merge sort be used to count inversions in O(n log n)? If you can swap any two elements (not just adjacent), what is the minimum number of swaps then? How does duplicate handling change…
Full Details
🔒
Unlock all Ziphq questions
Full insider details, leaked discussions, and candidate experiences.
Get full access — $100 a year, unlimited accessAbout This Question
This is a reported interview question from a ziphq interview during the phone round.
It covers the following topics: Phone, Sorting, Coding, Arrays, Onsite .
More Ziphq Interview Questions
InterviewDB
Catch Me If You Can: Optimal Pursuer Movement on a Grid
InterviewDB
Conditional Check: Evaluate Boolean Expressions with Variables
InterviewDB
Ziphq SWE Phone - Convert Email
InterviewDB
Display Strings: Format and Wrap Text to Fit a Fixed-Width Screen
InterviewDB
Furthest Distance Reachable with Limited Fuel Stops