2022-05-31
Description
Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character.
Note that after backspacing an empty text, the text will continue empty.
Example 1:
Input: s = "ab#c", t = "ad#c"
Output: true
Explanation: Both s and t become "ac".Example 2:
Input: s = "ab##", t = "c#d#"
Output: true
Explanation: Both s and t become "".Example 3:
Input: s = "a#c", t = "b"
Output: false
Explanation: s becomes "c" while t becomes "b".Constraints:
1 <= s.length, t.length <= 200sandtonly contain lowercase letters and'#'characters.
Follow up: Can you solve it in O(n) time and O(1) space?
Solution
Approach #0
Approach #1
Description
You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [start[i], end[i]] and secondList[j] = [start[j], end[j]]. Each list of intervals is pairwise disjoint and in sorted order.
Return the intersection of these two interval lists.
A closed interval [a, b] (with a <= b) denotes the set of real numbers x with a <= x <= b.
The intersection of two closed intervals is a set of real numbers that are either empty or represented as a closed interval. For example, the intersection of [1, 3] and [2, 4] is [2, 3].
Example 1:

Example 2:
Constraints:
0 <= firstList.length, secondList.length <= 1000firstList.length + secondList.length >= 10 <= start[i] < end[i] <= 10^9end[i] < start[i+1]0 <= start[j] < end[j] <= 10^9end[j] < start[j+1]
Solution
Approach #0
Approach #1
Description
You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).
Find two lines that together with the x-axis form a container, such that the container contains the most water.
Return the maximum amount of water a container can store.
Notice that you may not slant the container.
Example 1:

Example 2:
Constraints:
n == height.length2 <= n <= 10^50 <= height[i] <= 10^4
Solution
Approach #0
Last updated