-
Notifications
You must be signed in to change notification settings - Fork 130
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
Add: new #575
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
problems/adding-two-negabinary-numbers/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>: 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> | ||
|
||
<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> </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> </p> | ||
|
||
<p><strong>Note:</strong></p> | ||
|
||
<ol> | ||
<li><code>1 <= arr1.length <= 1000</code></li> | ||
<li><code>1 <= arr2.length <= 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
problems/fixed-point/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.