Class IntervalComparator is public, should be declared in a file named

  • 0

    public class IntervalComparator implements Comparator<Interval>{
    public int compare(Interval l1,Interval l2){
    return l1.start-l2.start;

    why this class cannot be declared public?

  • 0

    In java each public class should be declared in the respective file named same to the class name.

Log in to reply

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