Code
基本概念同:Binary Search 101,解題邏輯和 Capacity To Ship Packages Within D Days ㄧ樣。
Time Complexity: , Space Complexity:
注意 sum += (num + divisor - 1) / divisor;
就是 sum += (num - 1) / divisor + 1;
Search
基本概念同:Binary Search 101,解題邏輯和 Capacity To Ship Packages Within D Days ㄧ樣。
Time Complexity: O(n⋅log(r−l)), Space Complexity: O(1)
注意 sum += (num + divisor - 1) / divisor;
就是 sum += (num - 1) / divisor + 1;