🎨
CMMobileBook
  • CMoney Mobile Book
  • Git主題
    • Git 基本知識
    • Git 使用方法
    • Git Flow 開發方式
    • Commit Message 規則
    • GitLab + SSH key
    • 相關學習網站
    • 延伸 Bitbucket 操作
  • Scrum主題
    • Scrum 基本知識
  • 程式練習題
    • 前言
    • 物件導向練習
      • StopWatch
    • Foundation 程式練習
      • 合法回文-1 Valid Palindrome
      • Reformat Date
      • Day of the Year
      • Peak Index in a Mountain Array
      • Number of Days Between Two Dates
      • To lower case
      • Two Sum
      • Best Time to Buy and Sell Stock
      • Best Time to Buy and Sell Stock II
    • 條件邏輯練習
      • FizzBuzz
      • Single Number
      • Self Dividing Number
Powered by GitBook
On this page

Was this helpful?

  1. 程式練習題
  2. Foundation 程式練習

Number of Days Between Two Dates

PreviousPeak Index in a Mountain ArrayNextTo lower case

Last updated 4 years ago

Was this helpful?

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.

題目
Loading...LeetCode
Logo