SHARE
TWEET

Untitled

a guest Dec 15th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public int removeCoveredIntervals(int[][] intervals) {
  2.      
  3.        
  4.         Arrays.sort(intervals, (a,b) -> a[0] - b[0] == 0 ? b[1] - a[1] : a[0] - b[0]) ;
  5.        
  6.         int ans = 0;
  7.        
  8.         int i = 0;
  9.        
  10.         while (i < intervals.length)
  11.         {
  12.             int j = i;
  13.            
  14.             while (j < intervals.length && intervals[i][0] <= intervals[j][0] && intervals[i][1] >= intervals[j][1]) j++;
  15.            
  16.          
  17.            
  18.             ans++;
  19.             i = j;
  20.            
  21.         }
  22.        
  23.        
  24.        
  25.         return ans;
  26.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top