Merge a New Interval
Merge a new interval into a list of non-overlapping intervals.
Input: intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newInterval = [4,8]
Output: [[1,2],[3,10],[12,16]]
Explanation: The new interval overlaps with [3,5], [6,7], and [8,10], merging them all into the unified block [3,10].
Calculate how much rainwater can be trapped between elevation bars.
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.
Input: height = [4,2,0,3,2,5]
Output: 9
Explanation: Water is trapped between the boundaries of 4 and 5. The trapped volumes…
Pacific and Atlantic Water Flow
Calculate water flow from a matrix to the Pacific and Atlantic oceans.
Input: heights = [[2,1],[1,2]]
Output: [[0,0],[0,1],[1,0],[1,1]]
Explanation: All cells can flow to both oceans because water can move to adjacent cells of equal or lower height or directly off the edges.
Add Two Numbers Represented as Strings
Add two non-negative integers represented as strings.
Input: num1 = "456", num2 = "77"
Output: "533"
Explanation: Performs character-by-character addition from right to left, carrying the 1 from 6+7=13 to the next decimal place.