Java Simple solution


  • 0
    G

    class Solution {
    public int findMinDifference(List<String> timePoints) {

       int[][] map = new int[36][60];
        
        for(String s : timePoints){
            int h = Integer.parseInt(s.substring(0, 2));
            int m = Integer.parseInt(s.substring(3, 5));
            
            if(map[h][m] == 1)
                return 0;
            
            map[h][m] = 1;
                        
            if(h < 12)
                map[h + 24][m] = 1;
        }
        
        int min = 720;
        int count = 720;
        for(int i = 0; i < 36; i++){
            for(int j = 0; j < 60; j++){
                count++;
                
                if(map[i][j] == 1){
                    min = Math.min(min, count);
                    
                    count = 0;
                }                
            }
        }
            
        return min;
    }
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.