4 string Java solution


  • 0
    G
    if(matrix==null || matrix.length==0 || matrix[0].length==0 || matrix[0][0]>target) return false;        
    int idx = Arrays.binarySearch(matrix, new int[]{target}, (a,b) -> a[0]-b[0]);
    if(idx>=0) return true;
    return Arrays.binarySearch(matrix[-idx-2], target)>=0;
    

Log in to reply
 

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