package com.fishercoder.solutions;

import com.fishercoder.common.classes.Interval;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei),
 * determine if a person could attend all meetings.

 For example,
 Given [[0, 30],[5, 10],[15, 20]],
 return false.*/
public class _252 {
    public boolean canAttendMeetings(Interval[] intervals) {

        List<Interval> list = new ArrayList();
        for (Interval interval : intervals) {
            list.add(interval);
        }

        Collections.sort(list, new Comparator<Interval>() {

            @Override
            public int compare(Interval o1, Interval o2) {
                if (o1.start > o2.start) {
                    return 1;
                } else {
                    return -1;
                }
            }

        });

        for (int i = 0; i < list.size() - 1; i++) {
            if (list.get(i).end > list.get(i + 1).start) {
                return false;
            }
        }
        return true;

    }
}

@@ -157,293 +157,75 @@
 til.
-Comparator;%0Aimport java.util.List;%0A/**Given an array of meeting time intervals consisting of start and end times %5B%5Bs1,e1%5D,%5Bs2,e2%5D,...%5D (si %3C ei),%0A * determine if a person could attend all meetings.%0A%0A For example,%0A Given %5B%5B0, 30%5D,%5B5, 10%5D,%5B15, 20%5D%5D,%0A return false.*/%0Apublic class _252 %7B%0A
+List;%0A%0Apublic class _252 %7B%0A    public static class Solution1 %7B%0A    
     
@@ -290,16 +290,20 @@
         
+ 
+   
 List%3CInt
@@ -333,16 +333,20 @@
 List();%0A
+    
         
@@ -395,16 +395,20 @@
         
+    
 list.add
@@ -419,35 +419,43 @@
 erval);%0A        
+   
+ 
 %7D%0A%0A
+    
         Collecti
@@ -473,116 +473,19 @@
 st, 
-new Comparator%3CInterval%3E() %7B%0A%0A            @Override%0A            public int compare(Interval o1, Interval o2)
+(o1, o2) -%3E
  %7B%0A 
@@ -647,23 +647,16 @@
    %7D
+);
 %0A%0A    
-    %7D);%0A%0A
     
@@ -711,24 +711,28 @@
             
+  
+  
 if (list.get
@@ -778,24 +778,28 @@
             
+    
 return false
@@ -804,34 +804,42 @@
 se;%0A            
-%7D%0A
+    %7D%0A    
         %7D%0A      
@@ -836,24 +836,28 @@
   %7D%0A        
+    
 return true;
@@ -857,16 +857,25 @@
 n true;%0A
+        %7D
 %0A    %7D%0A%7D

refactor 252