Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
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.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.