-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from asdf2014/master
some other
- Loading branch information
Showing
7 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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,17 @@ | ||
# Number of days of inactivity before an issue becomes stale | ||
daysUntilStale: 60 | ||
# Number of days of inactivity before a stale issue is closed | ||
daysUntilClose: 7 | ||
# Issues with these labels will never be considered stale | ||
exemptLabels: | ||
- bug | ||
- security | ||
# Label to use when marking an issue as stale | ||
staleLabel: stale | ||
# Comment to post when marking an issue as stale. Set to `false` to disable | ||
markComment: > | ||
This issue has been automatically marked as stale because it has not had | ||
recent activity. It will be closed if no further activity occurs. Thank you | ||
for your contributions. | ||
# Comment to post when closing a stale issue. Set to `false` to disable | ||
closeComment: false |
This file contains 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 @@ | ||
scanner: | ||
diff_only: True # If False, the entire file touched by the Pull Request is scanned for errors. If True, only the diff is scanned. | ||
linter: pycodestyle # Other option is flake8 | ||
|
||
pycodestyle: # Same as scanner.linter value. Other option is flake8 | ||
max-line-length: 100 # Default is 79 in PEP 8 | ||
ignore: # Errors and warnings to ignore | ||
- W504 # line break after binary operator | ||
- E402 # module level import not at top of file | ||
- E731 # do not assign a lambda expression, use a def | ||
- C406 # Unnecessary list literal - rewrite as a dict literal. | ||
- E741 # ambiguous variable name | ||
|
||
no_blank_comment: True # If True, no comment is made on PR without any errors. | ||
descending_issues_order: False # If True, PEP 8 issues in message will be displayed in descending order of line numbers in the file | ||
|
||
message: # Customize the comment made by the bot | ||
opened: # Messages when a new PR is submitted | ||
header: "Hello @{name}! Thanks for opening this PR. " | ||
# The keyword {name} is converted into the author's username | ||
footer: "Do see the [Hitchhiker's guide to code style](https://goo.gl/hqbW4r)" | ||
# The messages can be written as they would over GitHub | ||
updated: # Messages when new commits are added to the PR | ||
header: "Hello @{name}! Thanks for updating this PR. " | ||
footer: "" # Why to comment the link to the style guide everytime? :) | ||
no_errors: "There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: " |
This file contains 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,8 @@ | ||
{ | ||
"generalSettings": { | ||
"shouldScanRepo": true | ||
}, | ||
"checkRunSettings": { | ||
"vulnerableCheckRunConclusionLevel": "failure" | ||
} | ||
} |
This file contains 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,21 @@ | ||
# https://leetcode.com/problems/two-sum/ | ||
|
||
|
||
# 从 nums 中找到两个数,满足两数之和为 target | ||
def two_sum(nums, target): | ||
nums_len = len(nums) | ||
if nums_len < 1: | ||
return False | ||
cache = {} | ||
for i in range(nums_len): | ||
n = nums[i] | ||
if n in cache: | ||
# 2. 当前值 n 在 Map 中找到对应的 key 则拿出对应的 value,因为此时 n + key 刚好等于 target | ||
return [cache[n], i] | ||
else: | ||
# 1. 当前值 n 与目标值 target 的差值作为 Map 的 key,而下标作为 value | ||
cache[target - n] = i | ||
|
||
|
||
assert two_sum([2, 7, 11, 15], 9) == [0, 1] | ||
assert two_sum([4, 7, 0, 3], 3) == [2, 3] |
This file contains 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,2 @@ | ||
# 关于 | ||
leetcode刷题活动 |
This file contains 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,23 @@ | ||
# code | ||
|
||
``` python | ||
class Solution(object): | ||
def twoSum(self, nums, target): | ||
d = {} | ||
for i, n in enumerate(nums): | ||
m = target - n | ||
if m in d: | ||
return [d[m], i] | ||
else: | ||
d[n] = i | ||
``` | ||
|
||
## Testcase | ||
```python | ||
|
||
s = Solution() | ||
nums = [2,7,11,15] | ||
target = 9 | ||
|
||
assert s.twoSum(nums, target) == [0, 1] | ||
``` |
This file contains 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