Skip to content
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

【155-week1】总结 #65

Open
zhaozhifu0 opened this issue Apr 19, 2019 · 2 comments
Open

【155-week1】总结 #65

zhaozhifu0 opened this issue Apr 19, 2019 · 2 comments

Comments

@zhaozhifu0
Copy link

LeetCode 905. 按奇偶排序数组
思路:
(1)新建一个数组
(2)对原数组进行遍历,如果为奇数则添加到末尾,如果为偶数则添加到前面

之前用过sort,还真没不知道竟然是这样的sort!他会将元素转换为字符串,再根据字符串的第一个字母对应的ASCLL码来排序的。
弄不懂为什么和其他的高阶函数不一样,他直接修改了原数组。

@zhaozhifu0 zhaozhifu0 changed the title 【115-week1】总结 【155-week1】总结 Apr 19, 2019
@yanlingli3799
Copy link
Contributor

js语言不是很熟,没看懂sort干了啥,不过大致意思明白了。感觉可以优化一下哈,比如:(1)能不能不用额外数组?(2)能不能O(logn)时间复杂度?

@jonjia
Copy link

jonjia commented Apr 20, 2019

看了 83、905 文件命名和代码中的变量命名可以多斟酌下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants