LeetCode Problem

539. Minimum Time Difference Link to LeetCode 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. Example 1: Input: timePoints = ["23:59","00:00"] Output: 1 Example 2: Input: timePoints = ["00:00","23:59","00:00"] Output: 0 class Solution { public int findMinDifference(List timePoints) { List time = new ArrayList< > (); for (String t : timePoints) { String []x = t.split(":"); time.add((Integer.parseInt(x[0]) * 60) + Integer.parseInt(x[1])); } Collections.sort(time); int min = 1440; for (int i=1; i< time.size(); i++) { min = Math.min(min, time.get(i) - time.get(i-1)); } min = Math.min(min, (1440 + time.get(0)) - time.get(time.size()-1)); return min; } }