Available question text
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).
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 1649. Create Sorted Array through Instructions
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source