Python Easy Solution  with complete explanation
The code is pretty staright forward \nfirstly we are appending the new element in the interval and then sorting the array on ethe basis of first element and tha
The code is pretty staright forward \nfirstly we are appending the new element in the interval and then sorting the array on ethe basis of first element and that it what lambda x:x[0] is doing. After that we are checking if len< 0 then its empty and returning the new element. Otherwise we are checking for the condtion for merging the intervals. So here we have taken 0 and 1. Where 0 means the starting index and 1 means the ending index and after this condition is True and the intervals are merged we are just poping out the current i else we will continue till the end.\n\n        intervals.append(newInterval)\n        intervals.sort(key = lambda x:x[0])\n        print(intervals)\n        \n        if len(intervals)<0:\n            return newInterval\n        \n        i = 1\n\n        while i < len(intervals):\n            if intervals[i][0] <= intervals[i-1][1]:\n                intervals[i-1][0] = min(intervals[i-1][0], intervals[i][0])\n                \n                intervals[i-1][1] = max(intervals[i-1][1], intervals[i][1])\n                \n                intervals.pop(i)\n            else:\n                i+=1\n                continue\n                \n        return intervals\n\nUpvote if you find it helful
['Python', 'Python3']