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
Copy file name to clipboardExpand all lines: README.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,26 @@ LeetCode Problems' Solutions
54
54
55
55
| # | Title | Solution | Difficulty |
56
56
| :-: | - | - | :-: |
57
+
| <spanid="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
+
| <spanid="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
+
| <spanid="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
+
| <spanid="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
+
| <spanid="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 |
| <spanid="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
+
| <spanid="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
+
| <spanid="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 |
| <spanid="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
+
| <spanid="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
+
| <spanid="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
+
| <spanid="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
+
| <spanid="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
+
| <spanid="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
+
| <spanid="1057">1057</span> |[Campus Bikes](https://leetcode.com/problems/campus-bikes"校园自行车分配") 🔒 |[Go](https://github.com/openset/leetcode/tree/master/problems/campus-bikes)| Medium |
| <spanid="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 |
57
77
| <spanid="1054">1054</span> |[Distant Barcodes](https://leetcode.com/problems/distant-barcodes"距离相等的条形码")|[Go](https://github.com/openset/leetcode/tree/master/problems/distant-barcodes)| Medium |
58
78
| <spanid="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 |
59
79
| <spanid="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 |
[< 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>: as an array of 0s and 1s, from most significant bit to least significant bit. For example, <code>arr = [1,1,0,1]</code> represents the number <code>(-2)^3 + (-2)^2 + (-2)^0 = -3</code>. A number <code>arr</code> in <em>array format</em> is also guaranteed to have no leading zeros: either <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>
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.
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.
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.
Copy file name to clipboardExpand all lines: problems/exclusive-time-of-functions/README.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,13 +11,15 @@
11
11
12
12
## 636. Exclusive Time of Functions (Medium)
13
13
14
-
<p>On a single threaded CPU, we execute some functions. 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. Each function has a unique id between <code>0</code> and <code>N-1</code>.</p>
15
15
16
16
<p>We store logs in timestamp order that describe when a function is entered or exited.</p>
17
17
18
-
<p>Each log is a string with this format: <code>"{function_id}:{"start" | "end"}:{timestamp}"</code>. For example, <code>"0:start:3"</code> means the function with id <code>0</code> started at the beginning of timestamp <code>3</code>. <code>"1:end:2"</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>"{function_id}:{"start" | "end"}:{timestamp}"</code>. For example, <code>"0:start:3"</code> means the function with id <code>0</code> <strong>started at the beginning</strong> of timestamp <code>3</code>. <code>"1:end:2"</code> means the function with id <code>1</code> <strong>ended at the end</strong> of timestamp <code>2</code>.</p>
19
19
20
-
<p>A function's <em>exclusive time</em> is the number of units of time spent in this function. Note that this does not include any recursive calls to child functions.</p>
20
+
<p>A function's <em>exclusive time</em> is the number of units of time spent in this function. Note that this does <strong>not</strong> include any recursive 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>
21
23
22
24
<p>Return the exclusive time of each function, sorted by their function id.</p>
0 commit comments