diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 00000000..404baf07 --- /dev/null +++ b/.github/stale.yml @@ -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 diff --git a/.pep8speaks.yml b/.pep8speaks.yml new file mode 100644 index 00000000..57d06299 --- /dev/null +++ b/.pep8speaks.yml @@ -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: " diff --git a/.whitesource b/.whitesource new file mode 100644 index 00000000..f0569521 --- /dev/null +++ b/.whitesource @@ -0,0 +1,8 @@ +{ + "generalSettings": { + "shouldScanRepo": true + }, + "checkRunSettings": { + "vulnerableCheckRunConclusionLevel": "failure" + } +} \ No newline at end of file diff --git a/Codes/asdf2014/1_two_sum/two_sum.py b/Codes/asdf2014/1_two_sum/two_sum.py new file mode 100644 index 00000000..504f1c51 --- /dev/null +++ b/Codes/asdf2014/1_two_sum/two_sum.py @@ -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] diff --git a/Codes/mggger/README.md b/Codes/mggger/README.md new file mode 100644 index 00000000..929e4f77 --- /dev/null +++ b/Codes/mggger/README.md @@ -0,0 +1,2 @@ +# 关于 +leetcode刷题活动 \ No newline at end of file diff --git a/Codes/mggger/leetcode/1_two_sum.md b/Codes/mggger/leetcode/1_two_sum.md new file mode 100644 index 00000000..a97d8c45 --- /dev/null +++ b/Codes/mggger/leetcode/1_two_sum.md @@ -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] +``` \ No newline at end of file diff --git a/README.md b/README.md index f5652418..29826a1c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ +[](https://yuzhouwan.com/) + +[![](http://progressed.io/bar/7?scale=7&title=person&suffix=位)](https://yuzhouwan.com/posts/666/) +[![](http://progressed.io/bar/1?scale=38&title=covered&suffix=个)](https://yuzhouwan.com/posts/666/) +[![](http://progressed.io/bar/1?scale=1040&title=completed&suffix=题)](https://yuzhouwan.com/posts/666/) +[![](https://img.shields.io/badge/QQ%E7%BE%A4-128708857-blue.svg)](https://shang.qq.com/wpa/qunwpa?idkey=0692372b7f92845e80bc2e3e13dd4ae0bc4c0fcf88ef5864d279b21fb1317290) + + # Leetcode 组队刷题 ## 介绍 @@ -9,12 +17,12 @@ ### 报名途径 - 只需要在《[Algorithm](https://yuzhouwan.com/posts/666/)》文末留言,即可随时上车~~ + 只需要在《[Algorithm](https://yuzhouwan.com/posts/666/)》文末留言,即可随时参与 ### 参与方式 - 每位参与的小伙伴,都会获得代码仓库的 Collaborators 权限,可以自由地提交代码。在 `/Codes/${User}` 目录下,每人都将拥有一个自己的代码库 + 每位参与的小伙伴,都会获得代码仓库的 Collaborators 权限,可以自由地提交代码。在 `/Codes/${User}` 目录下,每人都将拥有一个自己的代码库。留下 Github 名称后,将很快会收到邀请函,大家可以在 [asdf2014 - algorithm - invitations](https://github.com/asdf2014/algorithm/invitations) 链接中认领 ### 刷题频率