C/C++教程

2022.01.03-synchronized实现

本文主要是介绍2022.01.03-synchronized实现,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

面试题: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]
这篇关于2022.01.03-synchronized实现的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!