LeetCode --- 1360. Number of Days Between Two Dates 解题报告

Posted 杨鑫newlfe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 1360. Number of Days Between Two Dates 解题报告相关的知识,希望对你有一定的参考价值。

Write a program to count the number of days between two dates.

The two dates are given as strings, their format is YYYY-MM-DD as shown in the examples.

Example 1:

Input: date1 = "2019-06-29", date2 = "2019-06-30"
Output: 1

Example 2:

Input: date1 = "2020-01-15", date2 = "2019-12-31"
Output: 15

Constraints:

  • The given dates are valid dates between the years 1971 and 2100.

所有代码均可在Github中找到:

下载链接

# -*- coding:utf-8 -*-
__author__ = \'yangxin_ryan\'
import datetime
"""
Solutions:
题目的意思就是计算两个时间的距离,
逻辑可以利用datetime.date

以上是关于LeetCode --- 1360. Number of Days Between Two Dates 解题报告的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode Strobogrammatic Number

LeetCode Strobogrammatic Number II

Vijos P1360 八数码问题

LeetCode Super Ugly Number

LeetCode Happy Number

LeetCode:Single Number