首页 > 其他分享 >leetcode-1360-easy

leetcode-1360-easy

时间:2023-04-14 22:37:41浏览次数:51  
标签:date1 dates date2 easy toEpochDay 2019 1360 LocalDate leetcode

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.

思路一:直接上 api

    public int daysBetweenDates(String date1, String date2) {
        LocalDate begin = LocalDate.parse(date1);
        LocalDate end = LocalDate.parse(date2);

        return Math.abs((int) (begin.toEpochDay() - end.toEpochDay()));
    }

标签:date1,dates,date2,easy,toEpochDay,2019,1360,LocalDate,leetcode
From: https://www.cnblogs.com/iyiluo/p/17320128.html

相关文章

  • leetcode-844-easy
    BackspaceStringCompareGiventwostringssandt,returntrueiftheyareequalwhenbotharetypedintoemptytexteditors.'#'meansabackspacecharacter.Notethatafterbackspacinganemptytext,thetextwillcontinueempty.Example1:......
  • leetcode-830-easy
    PositionsofLargeGroupsInastringsoflowercaseletters,theselettersformconsecutivegroupsofthesamecharacter.Forexample,astringlikes="abbxxxxzyy"hasthegroups"a","bb","xxxx","z"......
  • leetcode-812-easy
    LargestTriangleAreaGivenanarrayofpointsontheX-Yplanepointswherepoints[i]=[xi,yi],returntheareaofthelargesttrianglethatcanbeformedbyanythreedifferentpoints.Answerswithin10-5oftheactualanswerwillbeaccepted.Exampl......
  • leetcode-944-easy
    DeleteColumnsToMakeSortedYouaregivenanarrayofnstringsstrs,allofthesamelength.Thestringscanbearrangedsuchthatthereisoneoneachline,makingagrid.Forexample,strs=["abc","bce","cae"]canb......
  • 代码随想录算法训练营Day01 | LeetCode704 二分查找、Leetcode27 移除元素
    今日学习的视频和文章代码随想录数组基础复习基础知识代码随想录二分查找代码随想录移除元素LeetCode704二分查找题目链接:704.二分查找-力扣(Leetcode)以前学二分查找的时候,真的一直搞不清楚怎么操作左边界和有边界,以及循环的终止条件是什么,总是自己慢慢调试出来,......
  • LeetCode 周赛 340,质数 / 前缀和 / 极大化最小值 / 最短路 / 平衡二叉树
    本文已收录到AndroidFamily,技术和职场问题,请关注公众号[彭旭锐]提问。大家好,我是小彭。上周跟大家讲到小彭文章风格的问题,和一些朋友聊过以后,至少在算法题解方面确定了小彭的风格。虽然竞赛算法题的文章受众非常小,但却有很多像我一样的初学者,他们有兴趣参加但容易被题目难......
  • 视频直播点播EasyDSS迁移至新服务器,启动正常但无法访问是什么原因?
    EasyDSS能实现视频流媒体的上传、转码、存储、录像、推拉流、直播、点播等功能,具备超低延迟、超高画质、超大并发访问量等特点,可应用在多样化的场景中,如:在线课堂、教育直播、校园活动直播、企业培训、游戏直播等。平台支持HTTP、HLS、RTMP等播出协议,并且兼容多终端,如:Windows、Andro......
  • 在EasyCVR中点击电子地图,出现快照不消失情况是什么原因?
    EasyCVR视频融合平台基于云边端一体化架构,部署轻快、功能灵活,平台可支持多协议、多类型设备接入,包括:国标GB28181、RTMP、RTSP/Onvif、海康Ehome、海康SDK、大华SDK、宇视SDK等(具体见下图)。在视频能力上,可实现视频直播、录像、回放、检索、云存储、告警上报、语音对讲、电子地图、集......
  • LeetCode 108.将有序数组转换成二叉搜索树
    1.题目:给你一个整数数组nums,其中元素已经按升序排列,请你将其转换为一棵高度平衡二叉搜索树。高度平衡二叉树是一棵满足「每个节点的左右两个子树的高度差的绝对值不超过1」的二叉树。示例1:输入:nums=[-10,-3,0,5,9]输出:[0,-3,9,-10,null,5]解释:[0,-10,5,null,-3,null,......
  • [LeetCode] 1440. Jump Game V 跳跃游戏之五
    Givenanarrayof integers arr andaninteger d.Inonestepyoucanjumpfromindex i toindex:i+x where: i+x<arr.length and 0< x<=d.i-x where: i-x>=0 and 0< x<=d.Inaddition,youcanonlyjumpfromindex i toi......