DescriptionQ558
Q558FWASIC interview problem
Sort only a subrange
TechniquesSortingRangeDynamic array
DifficultyEasy
TopicArrays
LanguageSystemVerilog
Requirements3 checkpoints
01
Problem
Sort only the inclusive range [left, right] of a dynamic integer array in ascending order.
Example input and output
Use this case to check your interpretationInput
values = [9, 5, 3, 7, 1], left = 1, right = 3Output
[9, 3, 5, 7, 1]Explanation
Only indices 1 through 3 are sorted; the values outside the inclusive range remain untouched.
02
Requirements (3)
- Leave elements outside the selected range unchanged.
- Clamp the range to the legal array bounds.
- Return without work for an empty or single-element range.
