import java.util.*;  class GFG {          public static void main(String[] args)    {        int[][] interval            = { { 1, 3, 2 },                { 4, 5, 2 },                { 1, 5, 5 } };        int maxValue            = maxTwoNonOverLapping(interval);        System.out.println(maxValue);    }                  public static int maxTwoNonOverLapping(        int[][] interval)    {                        Arrays.sort(interval,                    (a, b) -> a[0] – b[0]);                                          PriorityQueue pq            = new PriorityQueue(                (a, b) -> a[0] – b[0]);                          int max = 0;        int ans = 0;                  for (int[] e : interval) {            while (!pq.isEmpty()) […]

Continue Reading