Skip to content

Commit 3c1b9ee

Browse files
author
Shuo
authored
Merge pull request #577 from openset/develop
Add: Related Topics
2 parents b8a8f59 + 5cdf6fe commit 3c1b9ee

File tree

4 files changed

+40
-1
lines changed
  • problems
    • adding-two-negabinary-numbers
    • flip-columns-for-maximum-number-of-equal-rows
    • greatest-common-divisor-of-strings
    • number-of-submatrices-that-sum-to-target

4 files changed

+40
-1
lines changed

problems/adding-two-negabinary-numbers/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,12 @@
3838
<li><code>arr1[i]</code> is <code>0</code> or <code>1</code></li>
3939
<li><code>arr2[i]</code> is <code>0</code> or <code>1</code></li>
4040
</ol>
41+
42+
### Related Topics
43+
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]
44+
45+
### Hints
46+
<details>
47+
<summary>Hint 1</summary>
48+
We can try to determine the last digit of the answer, then divide everything by 2 and repeat.
49+
</details>

problems/flip-columns-for-maximum-number-of-equal-rows/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,12 @@
6060
</div>
6161
</div>
6262
</div>
63+
64+
### Related Topics
65+
[[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)]
66+
67+
### Hints
68+
<details>
69+
<summary>Hint 1</summary>
70+
Flipping a subset of columns is like doing a bitwise XOR of some number K onto each row. We want rows X with X ^ K = all 0s or all 1s. This is the same as X = X^K ^K = (all 0s or all 1s) ^ K, so we want to count rows that have opposite bits set. For example, if K = 1, then we count rows X = (00000...001, or 1111....110).
71+
</details>

problems/greatest-common-divisor-of-strings/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/flip-columns-for-maximum-number-of-equal-rows "Flip Columns For Maximum Number of Equal Rows")
1111

12-
## 5076. Greatest Common Divisor of Strings (Easy)
12+
## 1071. Greatest Common Divisor of Strings (Easy)
1313

1414
<p>For strings <code>S</code> and <code>T</code>, we say &quot;<code>T</code> divides <code>S</code>&quot; if and only if <code>S = T + ... + T</code>&nbsp; (<code>T</code> concatenated with itself 1 or more times)</p>
1515

@@ -47,3 +47,12 @@
4747
<li><code>1 &lt;= str2.length &lt;= 1000</code></li>
4848
<li><code>str1[i]</code> and <code>str2[i]</code> are English uppercase letters.</li>
4949
</ol>
50+
51+
### Related Topics
52+
[[String](https://github.com/openset/leetcode/tree/master/tag/string/README.md)]
53+
54+
### Hints
55+
<details>
56+
<summary>Hint 1</summary>
57+
The greatest common divisor must be a prefix of each string, so we can try all prefixes.
58+
</details>

problems/number-of-submatrices-that-sum-to-target/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,15 @@ Next >
4747
<li><code>-1000 &lt;= matrix[i] &lt;= 1000</code></li>
4848
<li><code>-10^8 &lt;= target &lt;= 10^8</code></li>
4949
</ol>
50+
51+
### Related Topics
52+
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
53+
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
54+
[[Sliding Window](https://github.com/openset/leetcode/tree/master/tag/sliding-window/README.md)]
55+
56+
### Hints
57+
<details>
58+
<summary>Hint 1</summary>
59+
Using a 2D prefix sum, we can query the sum of any submatrix in O(1) time.
60+
Now for each (r1, r2), we can find the largest sum of a submatrix that uses every row in [r1, r2] in linear time using a sliding window.
61+
</details>

0 commit comments

Comments
 (0)