第 287 场周赛
class Solution:
def convertTime(self, current: str, correct: str) -> int:
d = int(correct[:2]) * 60 + int(correct[3:]) - (int(current[:2]) * 60 + int(current[3:]))
res = 0
for i in [60, 15, 5, 1]:
res += d // i
d %= i
return res
class Solution:
def findWinners(self, matches: List[List[int]]) -> List[List[int]]:
win, los = defaultdict(int), defaultdict(int)
for a, b in matches:
win[a] += 1
los[b] += 1
w = set(win) - set(los)
u = [x for x, v in los.items() if v == 1]
return [sorted(w), sorted(u)]
class Solution {
public int maximumCandies(int[] candies, long k) {
long sum = 0L;
for(int i : candies) sum += i;
if(sum < k) return 0;
if(sum == k) return 1;
long i = 1, j = sum / k;
while (i <= j){
long mid = (i + j)/2;
long cnt = 0L;
for(int num : candies){
cnt += num / mid;
}
if(cnt >= k) i = mid + 1;
else j = mid - 1;
}
return (int)i - 1;
}
}
|