Problem Statement | |||||||||||||
Every schoolgirl (and the occasional schoolboy) likes to skip rope. It's fine to go solo, but it's better still to have partners who can swing the rope and chant along. Ideally, the two children holding the rope are about as tall as the one doing the skipping. In this problem, we shall measure height in centimeters. Given a int[] containing the heights of your prospective partners, return the two that are closest to your own height, which is specified by a separate int. Break ties in favor of taller candidates, and sort the return values in non-descending order. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | It's possible for multiple candidates to have the same height. | ||||||||||||
Constraints | |||||||||||||
- | candidates contains between 2 and 50 elements, inclusive | ||||||||||||
- | each element of candidates is between 75 and 175, inclusive | ||||||||||||
- | height is between 75 and 175, inclusive | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|