面试题:synchronized实现
参考链接
https://xiaomi-info.github.io/2020/03/24/synchronized/
https://www.cnblogs.com/aspirant/p/11470858.html
每日一题
1185. 一周中的第几天
class Solution:
def dayOfTheWeek(self, day: int, month: int, year: int) -> str:
d = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
m = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30]
res = 0
cur = 1970
while cur < year:
res += 365
if cur % 4 == 0 and cur % 100 != 0 or cur % 400 == 0:
res += 1
cur += 1
if cur % 4 == 0 and cur % 100 != 0 or cur % 400 == 0:
m[2] = 29
res += sum(m[:month]) + day
return d[(res + 3) % 7]