sort-select-restore-idiom

Status: IN

Subsequence selection problems use a two-sort pattern: sort by value to select the top-k elements, then re-sort by original index to restore input order — correctness does not depend on sort stability.

Source: entries/2026/06/06/find-subsequence-of-length-k-with-the-largest-sum-solution.md

JSON