You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[Leetcode-167](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/)| Two Sum Ii Input Array Is Sorted |[c++](./leetcode/167.two-sum-ii-input-array-is-sorted.cpp), [python3](./leetcode/167.two-sum-ii-input-array-is-sorted.py)| Two Pointers | O\(N\)| O\(1\)| - |
649
650
|[Leetcode-653](https://leetcode.com/problems/two-sum-iv-input-is-a-bst/)| Two Sum Iv Input Is A Bst |[c++](./leetcode/653.two-sum-iv-input-is-a-bst.cpp), [python3](./leetcode/653.two-sum-iv-input-is-a-bst.py)| Two Pointers | O\(NH\)| O\(H\)| - |
650
651
|[Leetcode-680](https://leetcode.com/problems/valid-palindrome-ii/)| Valid Palindrome II |[c++](./leetcode/680.valid-palindrome-ii.cpp), [python3](./leetcode/680.valid-palindrome-ii.py)| Two Pointers | O\(N\)| O\(1\)| - |
652
+
|[Lintcode-861](https://www.lintcode.com/problem/k-empty-slots/)| K Empty Slots |[c++](./lintcode/861.k-empty-slots.cpp), [python3](./lintcode/861.k-empty-slots.py)| Two Pointers | O\(N\)| O\(N\)| Leetcode-683 |
651
653
|[Lintcode-386](https://www.lintcode.com/problem/longest-substring-with-at-most-k-distinct-characters/)| Longest Substring With At Most K Distinct Characters |[c++](./lintcode/386.longest-substring-with-at-most-k-distinct-characters.cpp), [python3](./lintcode/386.longest-substring-with-at-most-k-distinct-characters.py)| Two Pointers | O\(N\)| O\(K\)| Leetcode-159, 340 |
652
654
653
655
## Sliding Window
654
656
655
-
| Link | Problem(33) | Solution | Tag | Time | Space | Ref |
657
+
| Link | Problem(34) | Solution | Tag | Time | Space | Ref |
|[Lintcode-3724](https://www.lintcode.com/problem/distinct-numbers-in-each-subarray/)| Distinct Numbers In Each Subarray |[c++](./lintcode/3724.distinct-numbers-in-each-subarray.cpp), [python3](./lintcode/3724.distinct-numbers-in-each-subarray.py)| Sliding Window | O\(N\)| O\(K\)| Leetcode-1852 |
687
689
|[Lintcode-3675](https://www.lintcode.com/problem/minimum-swaps-to-group-all-1s-together/)| Minimum Swaps To Group All 1S Together |[c++](./lintcode/3675.minimum-swaps-to-group-all-1s-together.cpp), [python3](./lintcode/3675.minimum-swaps-to-group-all-1s-together.py)| Sliding Window | O\(N\)| O\(1\)| Leetcode-1151 |
688
690
|[Lintcode-642](https://www.lintcode.com/problem/moving-average-from-data-stream/)| Moving Average From Data Stream |[c++](./lintcode/642.moving-average-from-data-stream.cpp), [python3](./lintcode/642.moving-average-from-data-stream.py)| Sliding Window | O\(1\)| O\(K\)| Leetcode-346 |
691
+
|[Lintcode-3751](https://www.lintcode.com/problem/number-of-equal-count-substrings/)| Number Of Equal Count Substrings |[c++](./lintcode/3751.number-of-equal-count-substrings.cpp), [python3](./lintcode/3751.number-of-equal-count-substrings.py)| Sliding Window | O\(N\)| O\(N\)| Leetcode-2067 |
689
692
|[Lintcode-3756](https://www.lintcode.com/problem/number-of-unique-flavors-remaining-after-sharing-k-candies/)| Number Of Unique Flavors Remaining After Sharing K Candies |[c++](./lintcode/3756.number-of-unique-flavors-remaining-after-sharing-k-candies.cpp), [python3](./lintcode/3756.number-of-unique-flavors-remaining-after-sharing-k-candies.py)| Sliding Window | O\(N\)| O\(N\)| Leetcode-2107 |
|[Leetcode-863](https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/)| All Nodes Distance K In Binary Tree |[c++](./leetcode/863.all-nodes-distance-k-in-binary-tree.cpp), [python3](./leetcode/863.all-nodes-distance-k-in-binary-tree.py)| Depth-First Search | O\(N\)| O\(N\)| - |
|[Leetcode-938](https://leetcode.com/problems/range-sum-of-bst/)| Range Sum Of Bst |[c++](./leetcode/938.range-sum-of-bst.cpp), [python3](./leetcode/938.range-sum-of-bst.py)| Depth-First Search | O\(N\)| O\(W\)| - |
|[Leetcode-771](https://leetcode.com/problems/jewels-and-stones/)| Jewels And Stones |[c++](./leetcode/771.jewels-and-stones.cpp)| Other |\-|\-| - |
1121
1125
|[Leetcode-45](https://leetcode.com/problems/jump-game-ii/)| Jump Game II |[c++](./leetcode/45.jump-game-ii.cpp), [python3](./leetcode/45.jump-game-ii.py)| Other |\-|\-| - |
1122
1126
|[Leetcode-532](https://leetcode.com/problems/k-diff-pairs-in-an-array/)| K Diff Pairs In An Array |[c++](./leetcode/532.k-diff-pairs-in-an-array.cpp), [python3](./leetcode/532.k-diff-pairs-in-an-array.py)| Other |\-|\-| - |
1123
-
|[Leetcode-683](https://leetcode.com/problems/k-empty-slots/)| K Empty Slots |[c++](./leetcode/683.k-empty-slots.cpp), [python3](./leetcode/683.k-empty-slots.py)| Other |\-|\-| - |
1124
1127
|[Leetcode-368](https://leetcode.com/problems/largest-divisible-subset/)| Largest Divisible Subset |[c++](./leetcode/368.largest-divisible-subset.cpp), [python3](./leetcode/368.largest-divisible-subset.py)| Other |\-|\-| - |
1125
1128
|[Leetcode-747](https://leetcode.com/problems/largest-number-at-least-twice-of-others/)| Largest Number At Least Twice Of Others |[c++](./leetcode/747.largest-number-at-least-twice-of-others.cpp)| Other |\-|\-| - |
1126
1129
|[Leetcode-17](https://leetcode.com/problems/letter-combinations-of-a-phone-number/)| Letter Combinations Of A Phone Number |[c++](./leetcode/17.letter-combinations-of-a-phone-number.cpp), [python3](./leetcode/17.letter-combinations-of-a-phone-number.py)| Other |\-|\-| - |
// Tag: String, Tree, Depth-First Search, Binary Tree
2
+
// Time: O(N)
3
+
// Space: O(H)
4
+
// Ref: -
5
+
// Note: -
6
+
// Video: https://youtu.be/dcu39zy0Uac
7
+
8
+
// We run a preorder depth-first search (DFS) on the root of a binary tree.
9
+
// At each node in this traversal, we output D dashes (where D is the depth of this node), then we output the value of this node. If the depth of a node is D, the depth of its immediate child is D + 1. The depth of the root node is 0.
10
+
// If a node has only one child, that child is guaranteed to be the left child.
11
+
// Given the output traversal of this traversal, recover the tree and return its root.
12
+
//
13
+
// Example 1:
14
+
//
15
+
//
16
+
// Input: traversal = "1-2--3--4-5--6--7"
17
+
// Output: [1,2,5,3,4,6,7]
18
+
//
19
+
// Example 2:
20
+
//
21
+
//
22
+
// Input: traversal = "1-2--3---4-5--6---7"
23
+
// Output: [1,2,5,3,null,6,null,4,null,7]
24
+
//
25
+
// Example 3:
26
+
//
27
+
//
28
+
// Input: traversal = "1-401--349---90--88"
29
+
// Output: [1,401,null,349,88,90]
30
+
//
31
+
//
32
+
// Constraints:
33
+
//
34
+
// The number of nodes in the original tree is in the range [1, 1000].
# Tag: String, Tree, Depth-First Search, Binary Tree
2
+
# Time: O(N)
3
+
# Space: O(H)
4
+
# Ref: -
5
+
# Note: -
6
+
# Video: https://youtu.be/dcu39zy0Uac
7
+
8
+
# We run a preorder depth-first search (DFS) on the root of a binary tree.
9
+
# At each node in this traversal, we output D dashes (where D is the depth of this node), then we output the value of this node. If the depth of a node is D, the depth of its immediate child is D + 1. The depth of the root node is 0.
10
+
# If a node has only one child, that child is guaranteed to be the left child.
11
+
# Given the output traversal of this traversal, recover the tree and return its root.
12
+
#
13
+
# Example 1:
14
+
#
15
+
#
16
+
# Input: traversal = "1-2--3--4-5--6--7"
17
+
# Output: [1,2,5,3,4,6,7]
18
+
#
19
+
# Example 2:
20
+
#
21
+
#
22
+
# Input: traversal = "1-2--3---4-5--6---7"
23
+
# Output: [1,2,5,3,null,6,null,4,null,7]
24
+
#
25
+
# Example 3:
26
+
#
27
+
#
28
+
# Input: traversal = "1-401--349---90--88"
29
+
# Output: [1,401,null,349,88,90]
30
+
#
31
+
#
32
+
# Constraints:
33
+
#
34
+
# The number of nodes in the original tree is in the range [1, 1000].
0 commit comments