public class Solution {
    public int[] findRightInterval(Interval[] intervals) {         //TLE  one easy improvement to to use binary search here  binary search is a good friend of sort.
        HashMap<Interval, Integer> index = new HashMap<Interval,Integer>();                   
        if(intervals == null || intervals.length<=1){
            return new int[]{-1};
        }
        int[] res = new int[intervals.length];
        //List<Interval> endInsrc  = new LinkedList<Interval>();
        List<Interval> startInsrc = new LinkedList<Interval>();
        for(int i=0; i<intervals.length;i++){
            index.put(intervals[i],i);
            startInsrc.add(intervals[i]);
        }
        
        Collections.sort(startInsrc,(a,b)->a.start-b.start);
        for(int i=0;i<intervals.length;i++){
            Interval cur = intervals[i];
            Interval minRight = null;
            for(int j=0;j<startInsrc.size();j++){
                if(startInsrc.get(j).start>=cur.end){
                    minRight = startInsrc.get(j);
                    break;
                }
            }
            if(minRight == null) res[i] = -1;
            else res[i] = index.get(minRight);
        }

        return res;
    }
    public int[] findRightInterval(Interval[] intervals) {
        int[] result = new int[intervals.length];
        java.util.NavigableMap<Integer, Integer> intervalMap = new TreeMap<>();
        
        for (int i = 0; i < intervals.length; ++i) {
            intervalMap.put(intervals[i].start, i);    
        }
        
        for (int i = 0; i < intervals.length; ++i) {
            Map.Entry<Integer, Integer> entry = intervalMap.ceilingEntry(intervals[i].end);
            result[i] = (entry != null) ? entry.getValue() : -1;
        }
        
        return result;
    }

} 
@@ -1251,32 +1251,33 @@
 indRightInterval
+2
 (Interval%5B%5D inte
@@ -1811,10 +1811,1417 @@
 %0A    %7D%0A%0A
+    public int%5B%5D findRightInterval3(Interval%5B%5D intervals) %7B%0A        int %5B%5D answer = new int %5Bintervals.length%5D;%0A        List%3Cint%5B%5D%3E sortedIntervals = new ArrayList%3C%3E();%0A        %0A        for (int idx = 0; idx %3C intervals.length; idx ++)%0A            sortedIntervals.add(new int%5B%5D %7B intervals %5Bidx%5D.start, idx %7D);%0A        %0A        Collections.sort (sortedIntervals, new Comparator%3Cint%5B%5D%3E() %7B%0A            @Override%0A            public int compare(int%5B%5D o1, int%5B%5D o2) %7B%0A                return o1 %5B0%5D - o2 %5B0%5D;%0A            %7D%0A        %7D);%0A        %0A        for (int idx = 0; idx %3C intervals.length; idx ++) %7B%0A            int search = intervals %5Bidx%5D.end;%0A            int low = 0, high = sortedIntervals.size() - 1;%0A            boolean found = false;%0A            %0A            int mid = -1;%0A            while (low %3C= high) %7B%0A                mid = (low + high) %3E%3E%3E 1;%0A                if (sortedIntervals.get(mid)%5B0%5D %3E search)%0A                    high = mid - 1;%0A                else if (sortedIntervals.get(mid)%5B0%5D %3C search)%0A                    low = mid + 1;%0A                else %7B%0A                    answer%5Bidx%5D = sortedIntervals.get(mid)%5B1%5D;%0A                    found = true; break;%0A                %7D%0A            %7D%0A%0A            answer%5Bidx%5D = (!found) ? (low %3C sortedIntervals.size() && high %3C sortedIntervals.size() ? sortedIntervals.get(low)%5B1%5D : -1) : answer%5Bidx%5D;%0A        %7D%0A        %0A        return answer;%0A    %7D%0A%0A
 %7D 

Add binary Search