Practice: Sorting
0 of 4 solved
About these problems
Apply, Connect, Reason and Stretch describe difficulty within this topic, not an official contest rating. Open any problem in any order; reading the chapter first is optional.
- 1Ordered readingsYou are given a list of n integers a1, a2, ..., an. Print the values in nondecreasing order, from smallest to largest, keeping every copy of repeated values.ApplyNot started
- 2Results orderThere are n participants. Each has a distinct integer id and a score. Print the ids ordered by decreasing score; participants with equal scores are ordered by increasing id.ConnectNot started
- 3Closest readingsYou are given a list of n integers a1, a2, ..., an. Find the smallest value of |ai - aj| over all pairs of different positions i ≠ j.ReasonNot started
- 4Compact coordinatesYou are given a list of n integers a1, a2, ..., an. Replace every value by its rank among the distinct values of the list in increasing order: the smallest distinct value has rank 1, the next has rank 2, and so on. Equal values receive equal ranks. Print the ranks in the original input order.StretchNot started