Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 43217b9

Browse files
author
openset
committed
Add: new
1 parent 4873ff2 commit 43217b9

File tree

32 files changed

+710
-7
lines changed

32 files changed

+710
-7
lines changed

‎README.md‎

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

5555
| # | Title | Solution | Difficulty |
5656
| :-: | - | - | :-: |
57+
| <span id="1074">1074</span> | [Number of Submatrices That Sum to Target](https://leetcode.com/problems/number-of-submatrices-that-sum-to-target "元素和为目标值的子矩阵数量") | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-submatrices-that-sum-to-target) | Hard |
58+
| <span id="1073">1073</span> | [Adding Two Negabinary Numbers](https://leetcode.com/problems/adding-two-negabinary-numbers "负二进制数相加") | [Go](https://github.com/openset/leetcode/tree/master/problems/adding-two-negabinary-numbers) | Medium |
59+
| <span id="1072">1072</span> | [Flip Columns For Maximum Number of Equal Rows](https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows "按列翻转得到最大值等行数") | [Go](https://github.com/openset/leetcode/tree/master/problems/flip-columns-for-maximum-number-of-equal-rows) | Medium |
60+
| <span id="1071">1071</span> | [Greatest Common Divisor of Strings](https://leetcode.com/problems/greatest-common-divisor-of-strings "字符串的最大公因子") | [Go](https://github.com/openset/leetcode/tree/master/problems/greatest-common-divisor-of-strings) | Easy |
61+
| <span id="1070">1070</span> | [Product Sales Analysis III](https://leetcode.com/problems/product-sales-analysis-iii) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-iii) | Medium |
62+
| <span id="1069">1069</span> | [Product Sales Analysis II](https://leetcode.com/problems/product-sales-analysis-ii) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-ii) | Easy |
63+
| <span id="1068">1068</span> | [Product Sales Analysis I](https://leetcode.com/problems/product-sales-analysis-i) 🔒 | [MySQL](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-i) | Easy |
64+
| <span id="1067">1067</span> | [Digit Count in Range](https://leetcode.com/problems/digit-count-in-range "范围内的数字计数") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/digit-count-in-range) | Hard |
65+
| <span id="1066">1066</span> | [Campus Bikes II](https://leetcode.com/problems/campus-bikes-ii "校园自行车分配 II") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/campus-bikes-ii) | Medium |
66+
| <span id="1065">1065</span> | [Index Pairs of a String](https://leetcode.com/problems/index-pairs-of-a-string "字符串的索引对") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/index-pairs-of-a-string) | Easy |
67+
| <span id="1064">1064</span> | [Fixed Point](https://leetcode.com/problems/fixed-point "不动点") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/fixed-point) | Easy |
68+
| <span id="1063">1063</span> | [Number of Valid Subarrays](https://leetcode.com/problems/number-of-valid-subarrays "有效子数组的数目") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/number-of-valid-subarrays) | Hard |
69+
| <span id="1062">1062</span> | [Longest Repeating Substring](https://leetcode.com/problems/longest-repeating-substring "最长重复子串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/longest-repeating-substring) | Medium |
70+
| <span id="1061">1061</span> | [Lexicographically Smallest Equivalent String](https://leetcode.com/problems/lexicographically-smallest-equivalent-string "按字典序排列最小的等效字符串") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/lexicographically-smallest-equivalent-string) | Medium |
71+
| <span id="1060">1060</span> | [Missing Element in Sorted Array](https://leetcode.com/problems/missing-element-in-sorted-array "有序数组中的缺失元素") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/missing-element-in-sorted-array) | Medium |
72+
| <span id="1059">1059</span> | [All Paths from Source Lead to Destination](https://leetcode.com/problems/all-paths-from-source-lead-to-destination "从始点到终点的所有路径") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/all-paths-from-source-lead-to-destination) | Medium |
73+
| <span id="1058">1058</span> | [Minimize Rounding Error to Meet Target](https://leetcode.com/problems/minimize-rounding-error-to-meet-target "最小化舍入误差以满足目标") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/minimize-rounding-error-to-meet-target) | Medium |
74+
| <span id="1057">1057</span> | [Campus Bikes](https://leetcode.com/problems/campus-bikes "校园自行车分配") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/campus-bikes) | Medium |
75+
| <span id="1056">1056</span> | [Confusing Number](https://leetcode.com/problems/confusing-number "易混淆数") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/confusing-number) | Easy |
76+
| <span id="1055">1055</span> | [Shortest Way to Form String](https://leetcode.com/problems/shortest-way-to-form-string "形成字符串的最短路径") 🔒 | [Go](https://github.com/openset/leetcode/tree/master/problems/shortest-way-to-form-string) | Medium |
5777
| <span id="1054">1054</span> | [Distant Barcodes](https://leetcode.com/problems/distant-barcodes "距离相等的条形码") | [Go](https://github.com/openset/leetcode/tree/master/problems/distant-barcodes) | Medium |
5878
| <span id="1053">1053</span> | [Previous Permutation With One Swap](https://leetcode.com/problems/previous-permutation-with-one-swap "交换一次的先前排列") | [Go](https://github.com/openset/leetcode/tree/master/problems/previous-permutation-with-one-swap) | Medium |
5979
| <span id="1052">1052</span> | [Grumpy Bookstore Owner](https://leetcode.com/problems/grumpy-bookstore-owner "爱生气的书店老板") | [Go](https://github.com/openset/leetcode/tree/master/problems/grumpy-bookstore-owner) | Medium |
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <openset.wang@gmail.com> |-->
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/flip-columns-for-maximum-number-of-equal-rows "Flip Columns For Maximum Number of Equal Rows")
9+
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-submatrices-that-sum-to-target "Number of Submatrices That Sum to Target")
11+
12+
## 1073. Adding Two Negabinary Numbers (Medium)
13+
14+
<p>Given two numbers <code>arr1</code> and <code>arr2</code> in base <strong>-2</strong>, return the result of adding them together.</p>
15+
16+
<p>Each number is given in <em>array format</em>:&nbsp; as an array of 0s and 1s, from most significant bit to least significant bit.&nbsp; For example, <code>arr = [1,1,0,1]</code> represents the number <code>(-2)^3&nbsp;+ (-2)^2 + (-2)^0 = -3</code>.&nbsp; A number <code>arr</code> in <em>array format</em> is also guaranteed to have no leading zeros: either&nbsp;<code>arr == [0]</code> or <code>arr[0] == 1</code>.</p>
17+
18+
<p>Return the result of adding <code>arr1</code> and <code>arr2</code> in the same format: as an array of 0s and 1s with no leading zeros.</p>
19+
20+
<p>&nbsp;</p>
21+
22+
<p><strong>Example 1:</strong></p>
23+
24+
<pre>
25+
<strong>Input: </strong>arr1 = <span id="example-input-1-1">[1,1,1,1,1]</span>, arr2 = <span id="example-input-1-2">[1,0,1]</span>
26+
<strong>Output: </strong><span id="example-output-1">[1,0,0,0,0]
27+
</span><strong>Explanation: </strong>arr1 represents 11, arr2 represents 5, the output represents 16.
28+
</pre>
29+
30+
<p>&nbsp;</p>
31+
32+
<p><strong>Note:</strong></p>
33+
34+
<ol>
35+
<li><code>1 &lt;= arr1.length &lt;= 1000</code></li>
36+
<li><code>1 &lt;= arr2.length &lt;= 1000</code></li>
37+
<li><code>arr1</code> and <code>arr2</code> have no leading zeros</li>
38+
<li><code>arr1[i]</code> is <code>0</code> or <code>1</code></li>
39+
<li><code>arr2[i]</code> is <code>0</code> or <code>1</code></li>
40+
</ol>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <openset.wang@gmail.com> |-->
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/minimize-rounding-error-to-meet-target "Minimize Rounding Error to Meet Target")
9+
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/missing-element-in-sorted-array "Missing Element in Sorted Array")
11+
12+
## 1059. All Paths from Source Lead to Destination (Medium)
13+
14+
15+
16+
### Related Topics
17+
[[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
18+
[[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)]
19+
20+
### Hints
21+
<details>
22+
<summary>Hint 1</summary>
23+
What if we can reach to a cycle from the source node?
24+
</details>
25+
26+
<details>
27+
<summary>Hint 2</summary>
28+
Then the answer will be false, because we eventually get trapped in the cycle forever.
29+
</details>
30+
31+
<details>
32+
<summary>Hint 3</summary>
33+
What if the we can't reach to a cycle from the source node? Then we need to ensure that from all visited nodes from source the unique node with indegree = 0 is the destination node.
34+
</details>

‎problems/campus-bikes-ii/README.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <openset.wang@gmail.com> |-->
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/index-pairs-of-a-string "Index Pairs of a String")
9+
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/digit-count-in-range "Digit Count in Range")
11+
12+
## 1066. Campus Bikes II (Medium)
13+
14+
15+
16+
### Related Topics
17+
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
18+
[[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)]
19+
20+
### Similar Questions
21+
1. [Campus Bikes](https://github.com/openset/leetcode/tree/master/problems/campus-bikes) (Medium)
22+
23+
### Hints
24+
<details>
25+
<summary>Hint 1</summary>
26+
Model the problem with a dp(pos, mask) where pos represents the current bike to be assigned and mask the set of available workers.
27+
</details>

‎problems/campus-bikes/README.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <openset.wang@gmail.com> |-->
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/confusing-number "Confusing Number")
9+
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/minimize-rounding-error-to-meet-target "Minimize Rounding Error to Meet Target")
11+
12+
## 1057. Campus Bikes (Medium)
13+
14+
15+
16+
### Related Topics
17+
[[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)]
18+
[[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)]
19+
20+
### Similar Questions
21+
1. [Campus Bikes II](https://github.com/openset/leetcode/tree/master/problems/campus-bikes-ii) (Medium)
22+
23+
### Hints
24+
<details>
25+
<summary>Hint 1</summary>
26+
Sort the elements by distance then in case of tie, sort them by the index of the worker, and if there still ties sort then by the index of the bike.Follow up: Can you do this in less than O(nlogn) time, where n is the total number of pairs between workers and bikes?.
27+
</details>
28+
29+
<details>
30+
<summary>Hint 2</summary>
31+
Loop the sorted elements and match each pair of worker and bike if the given worker and bike where not used.
32+
</details>

‎problems/confusing-number/README.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <openset.wang@gmail.com> |-->
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/shortest-way-to-form-string "Shortest Way to Form String")
9+
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/campus-bikes "Campus Bikes")
11+
12+
## 1056. Confusing Number (Easy)
13+
14+
15+
16+
### Related Topics
17+
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]
18+
19+
### Similar Questions
20+
1. [Strobogrammatic Number](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number) (Easy)
21+
22+
### Hints
23+
<details>
24+
<summary>Hint 1</summary>
25+
Reverse each digit with their corresponding new digit if an invalid digit is found the return -1. After reversing the digits just compare the reversed number with the original number.
26+
</details>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <openset.wang@gmail.com> |-->
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/campus-bikes-ii "Campus Bikes II")
9+
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-i "Product Sales Analysis I")
11+
12+
## 1067. Digit Count in Range (Hard)
13+
14+
15+
16+
### Related Topics
17+
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]
18+
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
19+
20+
### Similar Questions
21+
1. [Number of Digit One](https://github.com/openset/leetcode/tree/master/problems/number-of-digit-one) (Hard)
22+
23+
### Hints
24+
<details>
25+
<summary>Hint 1</summary>
26+
Define a function f(x) to get the requested sum from 1 to x. So the answer will be f(hi) - f(lo - 1)
27+
</details>
28+
29+
<details>
30+
<summary>Hint 2</summary>
31+
In order to solve f(x) we need to do a DP over digits approach.
32+
</details>

‎problems/distant-barcodes/README.md‎

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

88
[< Previous](https://github.com/openset/leetcode/tree/master/problems/previous-permutation-with-one-swap "Previous Permutation With One Swap")
99

10-
Next >
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/shortest-way-to-form-string"Shortest Way to Form String")
1111

1212
## 1054. Distant Barcodes (Medium)
1313

‎problems/exclusive-time-of-functions/README.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111

1212
## 636. Exclusive Time of Functions (Medium)
1313

14-
<p>On a single threaded CPU, we execute some functions.&nbsp; Each function has a unique id between <code>0</code> and <code>N-1</code>.</p>
14+
<p>On a <strong>single threaded</strong> CPU, we execute some functions.&nbsp; Each function has a unique id between <code>0</code> and <code>N-1</code>.</p>
1515

1616
<p>We store logs in timestamp order that describe when a function is entered or exited.</p>
1717

18-
<p>Each log is a string with this format: <code>&quot;{function_id}:{&quot;start&quot; | &quot;end&quot;}:{timestamp}&quot;</code>.&nbsp; For example, <code>&quot;0:start:3&quot;</code>&nbsp;means the function with id <code>0</code> started at the beginning of timestamp <code>3</code>.&nbsp; <code>&quot;1:end:2&quot;</code> means the function with id <code>1</code> ended at the end of timestamp <code>2</code>.</p>
18+
<p>Each log is a string with this format: <code>&quot;{function_id}:{&quot;start&quot; | &quot;end&quot;}:{timestamp}&quot;</code>.&nbsp; For example, <code>&quot;0:start:3&quot;</code>&nbsp;means the function with id <code>0</code> <strong>started at the beginning</strong> of timestamp <code>3</code>.&nbsp; <code>&quot;1:end:2&quot;</code> means the function with id <code>1</code> <strong>ended at the end</strong> of timestamp <code>2</code>.</p>
1919

20-
<p>A function&#39;s <em>exclusive time</em>&nbsp;is the number of units of time spent in this function.&nbsp; Note that this does not include any recursive&nbsp;calls to child functions.</p>
20+
<p>A function&#39;s <em>exclusive time</em>&nbsp;is the number of units of time spent in this function.&nbsp; Note that this does <strong>not</strong> include any recursive&nbsp;calls to child functions.</p>
21+
22+
<p>The CPU is <strong>single threaded</strong> which means that only one function is being executed at a given time unit.</p>
2123

2224
<p>Return the exclusive time of each function, sorted by their function id.</p>
2325

‎problems/fixed-point/README.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author Openset <openset.wang@gmail.com> |-->
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/number-of-valid-subarrays "Number of Valid Subarrays")
9+
10+
[Next >](https://github.com/openset/leetcode/tree/master/problems/index-pairs-of-a-string "Index Pairs of a String")
11+
12+
## 1064. Fixed Point (Easy)
13+
14+
15+
16+
### Related Topics
17+
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
18+
[[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)]
19+
20+
### Hints
21+
<details>
22+
<summary>Hint 1</summary>
23+
Loop over the array and check the first index i such A[i] == i
24+
</details>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /