finding the conflicts in meetings given startTimes and end Times Code to find conflicts in a list of meetings given as input. 
Meetings are defined as {startTime, endTime}. I am using a Greedy Algorithm to find the conflicts. Wanted to know if there is a more efficient way of solving this problem.

Example:  

Input: `meetings[] = { {1, 5} {3, 7}, {2, 6}, {10, 15}, {5, 6}, {4, 100}}`  
Output: Number of Conflicts : 4


The code:

// Meeting Class
class Meeting implements Comparable&lt;Meeting&gt; {
    int startTime;
    int endTime;
    public Meeting(int startTime, int endTime) {
        super();
        this.startTime = startTime;
        this.endTime = endTime;
    }
    @Override
    public int compareTo(Meeting o) {
        if(this.startTime == o.startTime) return 0;
        if(this.startTime &lt; o.startTime) return -1;
       return 1;
    }

}


Class which computes the conflicts 

public class FindConflictingMeetingsProblem {
     // static function to find conflicts
    public static int findNumberOfConflicts(List&lt;Meeting&gt; meetings){

        // sort the meetings in ascending order of start time
        Collections.sort(meetings,new Comparator&lt;Meeting&gt;(){
            @Override
            public int compare(Meeting o1, Meeting o2) {
                return o1.compareTo(o2);
            }
        });

        int conflicts = 0;
        // count the conflicts
        for(int i = 0 ; i &lt; meetings.size();i++){
            if(i &gt; 1 &amp;&amp; meetings.get(i-1).endTime &gt; meetings.get(i).startTime){
                conflicts++;
            }
        }
        return conflicts;
    }

    public static void main(String[] args) {
            Meeting m1 = new Meeting(1, 2);
            Meeting m2 = new Meeting(2, 5);
            Meeting m4 = new Meeting(4, 5);
            Meeting m5 = new Meeting(7, 8);
            List&lt;Meeting&gt; meetingsList = new ArrayList&lt;Meeting&gt;();
            meetingsList.add(m1);
            meetingsList.add(m2);
            meetingsList.add(m4);
            meetingsList.add(m5);
            System.out.println(" Number of conflicts :"+findNumberOfConflicts(meetingsList));
     }
}
Advice 1

int startTime;
int endTime;


I suggest you hide them with private access modifier:

private int startTime;
private int endTime;


Advice 2

Elaborating on Advice 1 you can add the getters for the two above fields:

public int getStartTime() {
    return startTime;
}

...


Advice 3

 Collections.sort(meetings,new Comparator&lt;Meeting&gt;(){
                @Override
                public int compare(Meeting o1, Meeting o2) {
                    return o1.compareTo(o2);
                }
            });


Since you already have the compareTo method in your Meeting class, you can write more succinctly:

Collections.sort(meetings);


Advice 4

What comes to Meeting.compareTo, you can write shorter:

@Override
public int compareTo(Meeting o) {
    return Integer.compare(startTime, o.startTime);
}


Advice 5

Consider writing a method that tests whether two given meetings are conflicting each other:

public boolean conflictsWith(Meeting meeting) {
    if (endTime &lt;= meeting.startTime) {
        return false;
    }

    if (meeting.endTime &lt;= startTime) {
        return false;
    }

    return true;
}


Advice 6

Consider checking in the constructor of Meeting whether startTime &lt;= endTime:

private void checkStartAndEndTimes(int startTime, int endTime) {
    if (startTime &gt;= endTime) {
        throw new IllegalArgumentException("Start time (" + startTime + 
                ") &gt;= end time (" + endTime + ").");
    }
}


Advice 7

public Meeting(int startTime, int endTime) {
                super();
                ...


Above super does not buy you anything, consider removing it.

Finally

The main algorithm is now a little bit more readable:

class FindConflictingMeetingsProblem {

    public static int findNumberOfConflicts(List&lt;Meeting&gt; meetings) {
        Collections.sort(meetings);
        int conflicts = 0;

        for (int i = 0; i &lt; meetings.size() - 1; ++i) {
            if (meetings.get(i).conflictsWith(meetings.get(i + 1))) {
                conflicts++;
            }
        }

        return conflicts;
    }
}


Algorithm limitations

Consider this:

Meeting m1 = new Meeting(1, 10);
Meeting m2 = new Meeting(5, 9);
Meeting m3 = new Meeting(4, 7);
List&lt;Meeting&gt; meetingsList = new ArrayList&lt;&gt;();
meetingsList.add(m1);
meetingsList.add(m2);
meetingsList.add(m3);


The above will report 2, but there is 3 pairs of meetings that conflict each other.

Hope that helps.