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

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
yanglbme merged 2 commits into doocs:main from Qiu-IT:solution0137
Feb 17, 2023

Conversation

@Qiu-IT
Copy link
Member

@Qiu-IT Qiu-IT commented Feb 17, 2023

愿这次是作规范了 没有打搅到您。

Copy link
Member

我尝试运行了一下,发现未通过,结果是标题取错了,这是 137 题

yanglbme reacted with eyes emoji

Copy link
Member Author

Qiu-IT commented Feb 17, 2023

是 137题 思路和136一样 做题晕了 竟然给你添了这个麻烦

Copy link
Member Author

Qiu-IT commented Feb 17, 2023

请问需要重新在PR的 还是等候您审查就可以了 这样的麽

Copy link
Member

不需要重新提 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
Copy link
Member Author

Qiu-IT commented Feb 17, 2023

已经push 两份改动了REAMME 到分支上面了 谢谢您 (吐舌)

Copy link
Member Author

Qiu-IT commented Feb 17, 2023

我尝试运行了一下,发现未通过,结果是标题取错了,这是 137 题

原来是另外大大吖 方才都木有留意哩
实在处理得有点犯晕 给您们加添了不少工作量

@yanglbme yanglbme merged commit 006523f into doocs:main Feb 17, 2023
Copy link
Member

这个解法可以再优化一下,遍历不要包含最后一个元素在内,可以省去一个判断:

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]
 }
}
yanglbme and Qiu-IT reacted with thumbs up emoji

@Qiu-IT Qiu-IT deleted the solution0137 branch February 18, 2023 18:19
@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

Reviewers

@yanglbme yanglbme yanglbme approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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