Tag: mergeintervals

  • Data Structures & Algorithms in Java – Intervals – Merge Intervals

    Problem: Given an array of intervals , merge overlapping intervals and return the non overlapping array of intervals. For example, Given the array: [[1,3],[2,6],[8,10]] The output should be [[1,6],[8,10]] Try out the solution here: https://leetcode.com/problems/merge-intervals/ Solution: First sort the array , this makes it easier to merge overlapping intervals. Once sorted , compare two successive…