values. Distribute all of its elements into two **non-empty** groups A and B, with every element going into exactly one group.
The score of a split is |max(A) − min(B)|. Return the smallest score you can achieve.values=[9, 2, 15, 4] → 2
Putting 2 and 4 in the first group and 9 and 15 in the second gives |4 − 9| = 5. Better: first group [2], second group [4, 9, 15], giving |2 − 4| = 2.
values=[7, 7, 30] → 0
One 7 goes to the first group, the other 7 and 30 to the second: |7 − 7| = 0.
values=[9, 2, 15, 4]
2
Run checks the first 3 tests in your browser. Submit checks all 107 tests on the server, hidden ones included.