Leetcode 1649. Create Sorted Array through Instructions
Given an array of instructions, process elements left-to-right inserting each into an array and add cost = min(number of prior elements strictly less than x, number strictly greater than x); return the total cost modulo 1e9+7. The core challenge is maintaining dynamic order statistics (counts of elements < x and > x) efficiently (e.g., via coordinate compression + Fenwick/segment tree).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.