452. Minimum Number of Arrows to Burst Balloons
Last updated
Last updated
If you cannot pass [[-2147483646,-2147483645],[2147483646,2147483647]]
use a[b] - b[0], maybe overflow,
so use Integer.compare(a[0], b[0])
Apparently a new test case has been added recently. If you cannot pass this one, then it is because the result of subtraction is too large and thus the overflow is encountered. So don't use a-b
to compare when sorting. Use Integer.compare(a,b)
instead!!!
time: O(nlogn)
space: O(1)