-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
feat: add swift solutions to lc problem: No. 0137 #892
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
Conversation
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
yanglbme
yanglbme
requested changes
Feb 17, 2023
我尝试运行了一下,发现未通过,结果是标题取错了,这是 137 题
是 137题 思路和136一样 做题晕了 竟然给你添了这个麻烦
请问需要重新在PR的 还是等候您审查就可以了 这样的麽
不需要重新提 pr,直接 push 改动到这个分支就行
@Qiu-IT
Qiu-IT
changed the title
(削除) add swift solution to lc problem No. 0136 (削除ここまで)
(追記) add swift solution to lc problem No. 0137 (追記ここまで)
Feb 17, 2023
已经push 两份改动了REAMME 到分支上面了 谢谢您 (吐舌)
我尝试运行了一下,发现未通过,结果是标题取错了,这是 137 题
原来是另外大大吖 方才都木有留意哩
实在处理得有点犯晕 给您们加添了不少工作量
yanglbme
yanglbme
approved these changes
Feb 17, 2023
这个解法可以再优化一下,遍历不要包含最后一个元素在内,可以省去一个判断:
class Solution { func singleNumber(_ nums: [Int]) -> Int { var a = nums.sorted() var n = a.count for i in stride(from: 0, through: n - 2, by: 3) { if a[i] != a[i + 1] { return a[i] } } return a[n - 1] } }
同理,136 也是如此:
class Solution { func singleNumber(_ nums: [Int]) -> Int { var a = nums.sorted() var n = a.count for i in stride(from: 0, through: n - 2, by: 2) { if a[i] != a[i + 1] { return a[i] } } return a[n - 1] } }
@Qiu-IT
Qiu-IT
changed the title
(削除) add swift solution to lc problem No. 0137 (削除ここまで)
(追記) feat: add swift solutions to lc problem No. 0137 (追記ここまで)
Feb 21, 2023
@Qiu-IT
Qiu-IT
changed the title
(削除) feat: add swift solutions to lc problem No. 0137 (削除ここまで)
(追記) feat: add swift solutions to lc problem: No. 0137 (追記ここまで)
Feb 21, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
愿这次是作规范了 没有打搅到您。