//Question //https://leetcode.com/problems/merge-intervals/ class Solution { public int[][] merge(int[][] arr) { Stackst=new Stack<>(); Pair[] pairs=new Pair[arr.length]; for(int i=0;irs=new Stack<>(); int j=0; while(st.size()>0){ rs.push(st.pop()); j++; } int [][] merge=new int[j][2]; for(int i=0;i{ int st; int et; public Pair(int st,int et){ this.st=st; this.et=et; } public int compareTo(Pair other){ if(this.st!=other.st) return this.st-other.st; else return this.et-other.et; } } }