Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.
Notice that the solution set must not contain duplicate triplets.
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.
eg: Input: intervals = [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6]overlaps, merge them into [1,6].
思路
首先对 interval 进行排序,之后遍历 interval,如果该 interval 是第一个,或者当前的 merged 的尾部和当前 interval 没有相交,直接 push。反之对 merged 尾部的【1】进行修改。注意 A or B 的反为(A 反&B 反 ) 时间复杂度为 O(nlogn) 空间复杂度为 O(n)(sort)
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.