diff --git a/README.md b/README.md index 438dbe736..06535fd8f 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,10 @@ LeetCode Problems' Solutions | # | Title | Solution | Difficulty | | :-: | - | - | :-: | +| 1111 | [Maximum Nesting Depth of Two Valid Parentheses Strings](https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings "有效括号的嵌套深度") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-nesting-depth-of-two-valid-parentheses-strings) | Medium | +| 1110 | [Delete Nodes And Return Forest](https://leetcode.com/problems/delete-nodes-and-return-forest "删点成林") | [Go](https://github.com/openset/leetcode/tree/master/problems/delete-nodes-and-return-forest) | Medium | +| 1109 | [Corporate Flight Bookings](https://leetcode.com/problems/corporate-flight-bookings "航班预订统计") | [Go](https://github.com/openset/leetcode/tree/master/problems/corporate-flight-bookings) | Medium | +| 1108 | [Defanging an IP Address](https://leetcode.com/problems/defanging-an-ip-address "IP 地址无效化") | [Go](https://github.com/openset/leetcode/tree/master/problems/defanging-an-ip-address) | Easy | | 1107 | [New Users Daily Count](https://leetcode.com/problems/new-users-daily-count) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/new-users-daily-count) | Medium | | 1106 | [Parsing A Boolean Expression](https://leetcode.com/problems/parsing-a-boolean-expression "解析布尔表达式") | [Go](https://github.com/openset/leetcode/tree/master/problems/parsing-a-boolean-expression) | Hard | | 1105 | [Filling Bookcase Shelves](https://leetcode.com/problems/filling-bookcase-shelves "填充书架") | [Go](https://github.com/openset/leetcode/tree/master/problems/filling-bookcase-shelves) | Medium | diff --git a/problems/corporate-flight-bookings/README.md b/problems/corporate-flight-bookings/README.md new file mode 100644 index 000000000..a5e1b3f66 --- /dev/null +++ b/problems/corporate-flight-bookings/README.md @@ -0,0 +1,35 @@ + + + + + + + +[< Previous](https://github.com/openset/leetcode/tree/master/problems/defanging-an-ip-address "Defanging an IP Address") + +[Next >](https://github.com/openset/leetcode/tree/master/problems/delete-nodes-and-return-forest "Delete Nodes And Return Forest") + +## 1109. Corporate Flight Bookings (Medium) + +
There are n
flights, and they are labeled from 1
to n
.
We have a list of flight bookings. The i
-th booking bookings[i] = [i, j, k]
means that we booked k
seats from flights labeled i
to j
inclusive.
Return an array answer
of length n
, representing the number of seats booked on each flight in order of their label.
+
Example 1:
+ ++Input: bookings = [[1,2,10],[2,3,20],[2,5,25]], n = 5 +Output: [10,55,45,25,25] ++ +
+
Constraints:
+ +1 <= bookings.length <= 20000
1 <= bookings[i][0] <= bookings[i][1] <= n <= 20000
1 <= bookings[i][2] <= 10000
Given a valid (IPv4) IP address
, return a defanged version of that IP address.
A defanged IP address replaces every period "."
with "[.]"
.
+
Example 1:
+Input: address = "1.1.1.1" +Output: "1[.]1[.]1[.]1" +
Example 2:
+Input: address = "255.100.50.0" +Output: "255[.]100[.]50[.]0" ++
+
Constraints:
+ +address
is a valid IPv4 address.Given the root
of a binary tree, each node in the tree has a distinct value.
After deleting all nodes with a value in to_delete
, we are left with a forest (a disjoint union of trees).
Return the roots of the trees in the remaining forest. You may return the result in any order.
+ ++
Example 1:
+ ++Input: root = [1,2,3,4,5,6,7], to_delete = [3,5] +Output: [[1,2,null,4],[6],[7]] ++ +
+
Constraints:
+ +1000
.1
and 1000
.to_delete.length <= 1000
to_delete
contains distinct values between 1
and 1000
.A string is a valid parentheses string (denoted VPS) if and only if it consists of "("
and ")"
characters only, and:
AB
(A
concatenated with B
), where A
and B
are VPS's, or(A)
, where A
is a VPS.We can similarly define the nesting depth depth(S)
of any VPS S
as follows:
depth("") = 0
depth(A + B) = max(depth(A), depth(B))
, where A
and B
are VPS'sdepth("(" + A + ")") = 1 + depth(A)
, where A
is a VPS.For example, ""
, "()()"
, and "()(()())"
are VPS's (with nesting depths 0, 1, and 2), and ")("
and "(()"
are not VPS's.
+ +
Given a VPS seq, split it into two disjoint subsequences A
and B
, such that A
and B
are VPS's (and A.length + B.length = seq.length
).
Now choose any such A
and B
such that max(depth(A), depth(B))
is the minimum possible value.
Return an answer
array (of length seq.length
) that encodes such a choice of A
and B
: answer[i] = 0
if seq[i]
is part of A
, else answer[i] = 1
. Note that even though multiple answers may exist, you may return any of them.
+
Example 1:
+ ++Input: seq = "(()())" +Output: [0,1,1,1,1,0] ++ +
Example 2:
+ ++Input: seq = "()(())()" +Output: [0,0,0,1,1,0,1,1] ++ +
+
Constraints:
+ +1 <= text.size <= 10000