Skip to content

Commit a273546

Browse files
author
openset
committed
Add: new
1 parent 73990c1 commit a273546

File tree

6 files changed

+271
-4
lines changed

6 files changed

+271
-4
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ LeetCode Problems' Solutions
5454

5555
| # | Title | Solution | Difficulty |
5656
| :-: | - | - | :-: |
57+
| <span id="1192">1192</span> | [Critical Connections in a Network](https://leetcode.com/problems/critical-connections-in-a-network "查找集群内的「关键连接」") | [Go](https://github.com/openset/leetcode/tree/master/problems/critical-connections-in-a-network) | Hard |
58+
| <span id="1191">1191</span> | [K-Concatenation Maximum Sum](https://leetcode.com/problems/k-concatenation-maximum-sum "K 次串联后最大子数组之和") | [Go](https://github.com/openset/leetcode/tree/master/problems/k-concatenation-maximum-sum) | Medium |
59+
| <span id="1190">1190</span> | [Reverse Substrings Between Each Pair of Parentheses](https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses "反转每对括号间的子串") | [Go](https://github.com/openset/leetcode/tree/master/problems/reverse-substrings-between-each-pair-of-parentheses) | Medium |
60+
| <span id="1189">1189</span> | [Maximum Number of Balloons](https://leetcode.com/problems/maximum-number-of-balloons "“气球” 的最大数量") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-number-of-balloons) | Easy |
61+
| <span id="1188">1188</span> | [Design Bounded Blocking Queue](https://leetcode.com/problems/design-bounded-blocking-queue) 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/design-bounded-blocking-queue) | Medium |
5762
| <span id="1187">1187</span> | [Make Array Strictly Increasing](https://leetcode.com/problems/make-array-strictly-increasing "使数组严格递增") | [Go](https://github.com/openset/leetcode/tree/master/problems/make-array-strictly-increasing) | Hard |
5863
| <span id="1186">1186</span> | [Maximum Subarray Sum with One Deletion](https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion "删除一次得到子数组最大和") | [Go](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray-sum-with-one-deletion) | Medium |
5964
| <span id="1185">1185</span> | [Day of the Week](https://leetcode.com/problems/day-of-the-week "一周中的第几天") | [Go](https://github.com/openset/leetcode/tree/master/problems/day-of-the-week) | Easy |
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/k-concatenation-maximum-sum "K-Concatenation Maximum Sum")
9+
                
10+
Next >
11+
12+
## 1192. Critical Connections in a Network (Hard)
13+
14+
<p>There are&nbsp;<code>n</code> servers numbered from&nbsp;<code>0</code>&nbsp;to&nbsp;<code>n-1</code> connected by&nbsp;undirected server-to-server <code>connections</code> forming a network where <code>connections[i] = [a, b]</code>&nbsp;represents a connection between servers <code>a</code>&nbsp;and <code>b</code>. Any server can reach any other server directly or indirectly through the network.</p>
15+
16+
<p>A <em>critical connection</em>&nbsp;is a connection that, if removed, will make some server unable to reach some other server.</p>
17+
18+
<p>Return all critical connections in the network in any order.</p>
19+
20+
<p>&nbsp;</p>
21+
<p><strong>Example 1:</strong></p>
22+
23+
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2019/09/03/1537_ex1_2.png" style="width: 198px; height: 248px;" /></strong></p>
24+
25+
<pre>
26+
<strong>Input:</strong> n = 4, connections = [[0,1],[1,2],[2,0],[1,3]]
27+
<strong>Output:</strong> [[1,3]]
28+
<strong>Explanation:</strong> [[3,1]] is also accepted.
29+
</pre>
30+
31+
<p>&nbsp;</p>
32+
<p><strong>Constraints:</strong></p>
33+
34+
<ul>
35+
<li><code>1 &lt;= n &lt;= 10^5</code></li>
36+
<li><code>n-1 &lt;= connections.length &lt;= 10^5</code></li>
37+
<li><code>connections[i][0] != connections[i][1]</code></li>
38+
<li>There are no repeated connections.</li>
39+
</ul>
40+
41+
### Related Topics
42+
[[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
43+
44+
### Hints
45+
<details>
46+
<summary>Hint 1</summary>
47+
Use Tarjan's algorithm.
48+
</details>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/reverse-substrings-between-each-pair-of-parentheses "Reverse Substrings Between Each Pair of Parentheses")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/critical-connections-in-a-network "Critical Connections in a Network")
11+
12+
## 1191. K-Concatenation Maximum Sum (Medium)
13+
14+
<p>Given an integer array <code>arr</code>&nbsp;and an integer <code>k</code>, modify the array by repeating it <code>k</code> times.</p>
15+
16+
<p>For example, if <code>arr&nbsp;= [1, 2]</code> and <code>k = 3 </code>then the modified array will be <code>[1, 2, 1, 2, 1, 2]</code>.</p>
17+
18+
<p>Return the maximum sub-array sum in the modified array. Note that the length of the sub-array can be <code>0</code>&nbsp;and its sum in that case is <code>0</code>.</p>
19+
20+
<p>As the answer can be very large, return the answer&nbsp;<strong>modulo</strong>&nbsp;<code>10^9 + 7</code>.</p>
21+
22+
<p>&nbsp;</p>
23+
<p><strong>Example 1:</strong></p>
24+
25+
<pre>
26+
<strong>Input:</strong> arr = [1,2], k = 3
27+
<strong>Output:</strong> 9
28+
</pre>
29+
30+
<p><strong>Example 2:</strong></p>
31+
32+
<pre>
33+
<strong>Input:</strong> arr = [1,-2,1], k = 5
34+
<strong>Output:</strong> 2
35+
</pre>
36+
37+
<p><strong>Example 3:</strong></p>
38+
39+
<pre>
40+
<strong>Input:</strong> arr = [-1,-2], k = 7
41+
<strong>Output:</strong> 0
42+
</pre>
43+
44+
<p>&nbsp;</p>
45+
<p><strong>Constraints:</strong></p>
46+
47+
<ul>
48+
<li><code>1 &lt;= arr.length &lt;= 10^5</code></li>
49+
<li><code>1 &lt;= k &lt;= 10^5</code></li>
50+
<li><code>-10^4 &lt;= arr[i] &lt;= 10^4</code></li>
51+
</ul>
52+
53+
### Related Topics
54+
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
55+
56+
### Hints
57+
<details>
58+
<summary>Hint 1</summary>
59+
How to solve the problem for k=1 ?
60+
</details>
61+
62+
<details>
63+
<summary>Hint 2</summary>
64+
Use Kadane's algorithm for k=1.
65+
</details>
66+
67+
<details>
68+
<summary>Hint 3</summary>
69+
What are the possible cases for the answer ?
70+
</details>
71+
72+
<details>
73+
<summary>Hint 4</summary>
74+
The answer is the maximum between, the answer for k=1, the sum of the whole array multiplied by k, or the maximum suffix sum plus the maximum prefix sum plus (k-2) multiplied by the whole array sum for k > 1.
75+
</details>

problems/make-array-strictly-increasing/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-subarray-sum-with-one-deletion "Maximum Subarray Sum with One Deletion")
99

10-
Next >
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/design-bounded-blocking-queue "Design Bounded Blocking Queue")
1111

1212
## 1187. Make Array Strictly Increasing (Hard)
1313

@@ -51,9 +51,6 @@ Next >
5151

5252
<p>&nbsp;</p>
5353

54-
### Related Topics
55-
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
56-
5754
### Hints
5855
<details>
5956
<summary>Hint 1</summary>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/design-bounded-blocking-queue "Design Bounded Blocking Queue")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/reverse-substrings-between-each-pair-of-parentheses "Reverse Substrings Between Each Pair of Parentheses")
11+
12+
## 1189. Maximum Number of Balloons (Easy)
13+
14+
<p>Given a string&nbsp;<code>text</code>, you want to use the characters of&nbsp;<code>text</code>&nbsp;to form as many instances of the word <strong>&quot;balloon&quot;</strong> as possible.</p>
15+
16+
<p>You can use each character in <code>text</code> <strong>at most once</strong>. Return the maximum number of instances that can be formed.</p>
17+
18+
<p>&nbsp;</p>
19+
<p><strong>Example 1:</strong></p>
20+
21+
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2019/09/05/1536_ex1_upd.JPG" style="width: 132px; height: 35px;" /></strong></p>
22+
23+
<pre>
24+
<strong>Input:</strong> text = &quot;nlaebolko&quot;
25+
<strong>Output:</strong> 1
26+
</pre>
27+
28+
<p><strong>Example 2:</strong></p>
29+
30+
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2019/09/05/1536_ex2_upd.JPG" style="width: 267px; height: 35px;" /></strong></p>
31+
32+
<pre>
33+
<strong>Input:</strong> text = &quot;loonbalxballpoon&quot;
34+
<strong>Output:</strong> 2
35+
</pre>
36+
37+
<p><strong>Example 3:</strong></p>
38+
39+
<pre>
40+
<strong>Input:</strong> text = &quot;leetcode&quot;
41+
<strong>Output:</strong> 0
42+
</pre>
43+
44+
<p>&nbsp;</p>
45+
<p><strong>Constraints:</strong></p>
46+
47+
<ul>
48+
<li><code>1 &lt;= text.length &lt;= 10^4</code></li>
49+
<li><code>text</code>&nbsp;consists of lower case English letters only.</li>
50+
</ul>
51+
52+
### Related Topics
53+
[[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)]
54+
[[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)]
55+
56+
### Hints
57+
<details>
58+
<summary>Hint 1</summary>
59+
Count the frequency of letters in the given string.
60+
</details>
61+
62+
<details>
63+
<summary>Hint 2</summary>
64+
Find the letter than can make the minimum number of instances of the word "balloon".
65+
</details>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](https://github.com/openset/leetcode/tree/master/problems/maximum-number-of-balloons "Maximum Number of Balloons")
9+
                
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/k-concatenation-maximum-sum "K-Concatenation Maximum Sum")
11+
12+
## 1190. Reverse Substrings Between Each Pair of Parentheses (Medium)
13+
14+
<p>Given a string <code>s</code> that consists of lower case English letters and brackets.&nbsp;</p>
15+
16+
<p>Reverse the strings&nbsp;in each&nbsp;pair of matching parentheses, starting&nbsp;from the innermost one.</p>
17+
18+
<p>Your result should <strong>not</strong> contain any bracket.</p>
19+
20+
<p>&nbsp;</p>
21+
22+
<p>&nbsp;</p>
23+
<p><strong>Example 1:</strong></p>
24+
25+
<pre>
26+
<strong>Input:</strong> s = &quot;(abcd)&quot;
27+
<strong>Output:</strong> &quot;dcba&quot;
28+
</pre>
29+
30+
<p><strong>Example 2:</strong></p>
31+
32+
<pre>
33+
<strong>Input:</strong> s = &quot;(u(love)i)&quot;
34+
<strong>Output:</strong> &quot;iloveu&quot;
35+
</pre>
36+
37+
<p><strong>Example 3:</strong></p>
38+
39+
<pre>
40+
<strong>Input:</strong> s = &quot;(ed(et(oc))el)&quot;
41+
<strong>Output:</strong> &quot;leetcode&quot;
42+
</pre>
43+
44+
<p><strong>Example 4:</strong></p>
45+
46+
<pre>
47+
<strong>Input:</strong> s = &quot;a(bcdefghijkl(mno)p)q&quot;
48+
<strong>Output:</strong> &quot;apmnolkjihgfedcbq&quot;
49+
</pre>
50+
51+
<p>&nbsp;</p>
52+
<p><strong>Constraints:</strong></p>
53+
54+
<ul>
55+
<li><code>0 &lt;= s.length &lt;= 2000</code></li>
56+
<li><code>s</code> only contains lower case English characters and parentheses.</li>
57+
<li>It&#39;s guaranteed that all parentheses are balanced.</li>
58+
</ul>
59+
60+
### Related Topics
61+
[[Stack](https://github.com/openset/leetcode/tree/master/tag/stack/README.md)]
62+
63+
### Hints
64+
<details>
65+
<summary>Hint 1</summary>
66+
Find all brackets in the string.
67+
</details>
68+
69+
<details>
70+
<summary>Hint 2</summary>
71+
Does the order of the reverse matter ?
72+
</details>
73+
74+
<details>
75+
<summary>Hint 3</summary>
76+
The order does not matter.
77+
</details>

0 commit comments

Comments
 (0)