LeetCode知识点总结 - 539

张开发
2026/4/6 22:20:32 15 分钟阅读

分享文章

LeetCode知识点总结 - 539
LeetCode 539. Minimum Time Difference考点难度MathMedium题目Given a list of 24-hour clock time points in “HH:MM” format, return the minimum minutes difference between any two time-points in the list.思路Turn “HH:MM” into the total number of minutes since midnight答案publicclassSolution{publicintfindMinDifference(ListStringtimePoints){intresInteger.MAX_VALUE;intNtimePoints.size();int[]cnewint[N];for(inti0;iN;i){StringstimePoints.get(i);c[i]Integer.parseInt(s.substring(0,2))*60Integer.parseInt(s.substring(3,5));}Arrays.sort(c);for(inti1;iN;i){resMath.min(res,c[i]-c[i-1]);}resMath.min(res,c[0](24*60-c[N-1]));returnres;}}

更多文章