1
var findMinDifference = function (timePoints) {2
const DAY_MINUTES = 24 * 60;5
for (let index = 0; index < timePoints.length; index++) {6
const time = timePoints[index];7
const [hours, minutes] = time.split(":");8
const totalMinutes = hours * 60 + +minutes;9
if (set.has(totalMinutes)) return 0;10
set.add(totalMinutes);13
const timeMinutes = [...set].sort((a, b) => a - b);14
return timeMinutes.reduce((min, time, index) => {15
const next = timeMinutes[index + 1];16
const diff = next ? next - time : DAY_MINUTES - time + timeMinutes[0];17
return Math.min(min, diff);