c++ Clean Easy Beat 80%


  • 0
    C

    '''
    class Solution {
    public://01:34
    int getInt(string & s){
    return ((s[0]-'0')*10 + (s[1]-'0'))*60 + (s[3]-'0')*10 + (s[4]-'0');
    }
    int findMinDifference(vector<string>& tp) {

        vector<int>time;
        for(int i =0;i<tp.size();i++){
            time.push_back(getInt(tp[i]));
        }
        sort(time.begin(),time.end());
        int minDiff = INT_MAX;
        for(int i=0;i<time.size()-1;i++){
            minDiff = min(minDiff,time[i+1]-time[i]);
        }
        minDiff = min(minDiff,(60*24)-(time.back()-time[0]));
        return minDiff;
        
    }
    

    };
    '''


Log in to reply
 

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