[DAY18]Max Min

Sherlock Chiou
1 min readOct 21, 2019

--

Solution: Greedy Method. We would sort the given array first to let the number with similar value get together. But there might be special condition like: 1, 2, 3, 6, 100, 110, 120, 130, 160. Given k = 5, the smallest unfairness would be 60 and subarr = [100, 110, 120 ,130, 160]. So we need to iterate through the sorted array to find the smallest unfairness.

--

--

Sherlock Chiou
Sherlock Chiou

Written by Sherlock Chiou

Be Effective and Optimize for Learning

No responses yet