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

Add: new #575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
awesee merged 1 commit into master from develop
Jun 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ LeetCode Problems' Solutions

| # | Title | Solution | Difficulty |
| :-: | - | - | :-: |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
Expand Down
40 changes: 40 additions & 0 deletions problems/adding-two-negabinary-numbers/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author Openset <openset.wang@gmail.com> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< 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")

[Next >](https://github.com/openset/leetcode/tree/master/problems/number-of-submatrices-that-sum-to-target "Number of Submatrices That Sum to Target")

## 1073. Adding Two Negabinary Numbers (Medium)

<p>Given two numbers <code>arr1</code> and <code>arr2</code> in base <strong>-2</strong>, return the result of adding them together.</p>

<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>

<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>

<p>&nbsp;</p>

<p><strong>Example 1:</strong></p>

<pre>
<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>
<strong>Output: </strong><span id="example-output-1">[1,0,0,0,0]
</span><strong>Explanation: </strong>arr1 represents 11, arr2 represents 5, the output represents 16.
</pre>

<p>&nbsp;</p>

<p><strong>Note:</strong></p>

<ol>
<li><code>1 &lt;= arr1.length &lt;= 1000</code></li>
<li><code>1 &lt;= arr2.length &lt;= 1000</code></li>
<li><code>arr1</code> and <code>arr2</code> have no leading zeros</li>
<li><code>arr1[i]</code> is <code>0</code> or <code>1</code></li>
<li><code>arr2[i]</code> is <code>0</code> or <code>1</code></li>
</ol>
34 changes: 34 additions & 0 deletions problems/all-paths-from-source-lead-to-destination/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author Openset <openset.wang@gmail.com> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/minimize-rounding-error-to-meet-target "Minimize Rounding Error to Meet Target")

[Next >](https://github.com/openset/leetcode/tree/master/problems/missing-element-in-sorted-array "Missing Element in Sorted Array")

## 1059. All Paths from Source Lead to Destination (Medium)



### Related Topics
[[Depth-first Search](https://github.com/openset/leetcode/tree/master/tag/depth-first-search/README.md)]
[[Graph](https://github.com/openset/leetcode/tree/master/tag/graph/README.md)]

### Hints
<details>
<summary>Hint 1</summary>
What if we can reach to a cycle from the source node?
</details>

<details>
<summary>Hint 2</summary>
Then the answer will be false, because we eventually get trapped in the cycle forever.
</details>

<details>
<summary>Hint 3</summary>
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.
</details>
27 changes: 27 additions & 0 deletions problems/campus-bikes-ii/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author Openset <openset.wang@gmail.com> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/index-pairs-of-a-string "Index Pairs of a String")

[Next >](https://github.com/openset/leetcode/tree/master/problems/digit-count-in-range "Digit Count in Range")

## 1066. Campus Bikes II (Medium)



### Related Topics
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]
[[Backtracking](https://github.com/openset/leetcode/tree/master/tag/backtracking/README.md)]

### Similar Questions
1. [Campus Bikes](https://github.com/openset/leetcode/tree/master/problems/campus-bikes) (Medium)

### Hints
<details>
<summary>Hint 1</summary>
Model the problem with a dp(pos, mask) where pos represents the current bike to be assigned and mask the set of available workers.
</details>
32 changes: 32 additions & 0 deletions problems/campus-bikes/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author Openset <openset.wang@gmail.com> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/confusing-number "Confusing Number")

[Next >](https://github.com/openset/leetcode/tree/master/problems/minimize-rounding-error-to-meet-target "Minimize Rounding Error to Meet Target")

## 1057. Campus Bikes (Medium)



### Related Topics
[[Greedy](https://github.com/openset/leetcode/tree/master/tag/greedy/README.md)]
[[Sort](https://github.com/openset/leetcode/tree/master/tag/sort/README.md)]

### Similar Questions
1. [Campus Bikes II](https://github.com/openset/leetcode/tree/master/problems/campus-bikes-ii) (Medium)

### Hints
<details>
<summary>Hint 1</summary>
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?.
</details>

<details>
<summary>Hint 2</summary>
Loop the sorted elements and match each pair of worker and bike if the given worker and bike where not used.
</details>
26 changes: 26 additions & 0 deletions problems/confusing-number/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author Openset <openset.wang@gmail.com> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/shortest-way-to-form-string "Shortest Way to Form String")

[Next >](https://github.com/openset/leetcode/tree/master/problems/campus-bikes "Campus Bikes")

## 1056. Confusing Number (Easy)



### Related Topics
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]

### Similar Questions
1. [Strobogrammatic Number](https://github.com/openset/leetcode/tree/master/problems/strobogrammatic-number) (Easy)

### Hints
<details>
<summary>Hint 1</summary>
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.
</details>
32 changes: 32 additions & 0 deletions problems/digit-count-in-range/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author Openset <openset.wang@gmail.com> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/campus-bikes-ii "Campus Bikes II")

[Next >](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-i "Product Sales Analysis I")

## 1067. Digit Count in Range (Hard)



### Related Topics
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]
[[Dynamic Programming](https://github.com/openset/leetcode/tree/master/tag/dynamic-programming/README.md)]

### Similar Questions
1. [Number of Digit One](https://github.com/openset/leetcode/tree/master/problems/number-of-digit-one) (Hard)

### Hints
<details>
<summary>Hint 1</summary>
Define a function f(x) to get the requested sum from 1 to x. So the answer will be f(hi) - f(lo - 1)
</details>

<details>
<summary>Hint 2</summary>
In order to solve f(x) we need to do a DP over digits approach.
</details>
2 changes: 1 addition & 1 deletion problems/distant-barcodes/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

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

## 1054. Distant Barcodes (Medium)

Expand Down
8 changes: 5 additions & 3 deletions problems/exclusive-time-of-functions/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@

## 636. Exclusive Time of Functions (Medium)

<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>
<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>

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

<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>
<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>

<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>
<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>

<p>The CPU is <strong>single threaded</strong> which means that only one function is being executed at a given time unit.</p>

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

Expand Down
24 changes: 24 additions & 0 deletions problems/fixed-point/README.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
<!--+----------------------------------------------------------------------+-->
<!--|@author Openset <openset.wang@gmail.com> |-->
<!--|@link https://github.com/openset |-->
<!--|@home https://github.com/openset/leetcode |-->
<!--+----------------------------------------------------------------------+-->

[< Previous](https://github.com/openset/leetcode/tree/master/problems/number-of-valid-subarrays "Number of Valid Subarrays")

[Next >](https://github.com/openset/leetcode/tree/master/problems/index-pairs-of-a-string "Index Pairs of a String")

## 1064. Fixed Point (Easy)



### Related Topics
[[Array](https://github.com/openset/leetcode/tree/master/tag/array/README.md)]
[[Binary Search](https://github.com/openset/leetcode/tree/master/tag/binary-search/README.md)]

### Hints
<details>
<summary>Hint 1</summary>
Loop over the array and check the first index i such A[i] == i
</details>
Loading

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