Available question text
Reorder arr1 so its elements follow the relative order given by arr2 (keeping duplicates together), and place elements not in arr2 at the end in ascending order. Typically solved by counting frequencies (or a hash map) to emit elements in arr2 order then output remaining values sorted.
Related questions
Continue with questions that share topics or the same question type.
- GCD Sort of an Array
Coding
- Minimum Pair Removal to Sort Array I
Coding
- Minimum Pair Removal to Sort Array II
Coding
- Minimum Replacements to Sort the Array
Coding · Array · Greedy · Math
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 1122. Relative Sort Array
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source