type
status
date
slug
summary
tags
category
icon
password
题目:
来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/SNJvJP 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
示例 1:
示例 2:
提示:
date.length == 10
date[4] == date[7] == '-'
,其他的date[i]
都是数字
date
表示的范围从 1900 年 1 月 1 日至 2019 年 12 月 31 日
思路:
- 对”-“进行分割,形成一个数组,0,1,2分别是年月日
- 对年进行判断,是闰年还是平年
- 使用数组来记录12个月中的天数
代码:
结果:

image-20220405111857320