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

12 - 算法 II #12

Open
4 of 9 tasks
Linjiayu6 opened this issue Jul 13, 2020 · 13 comments
Open
4 of 9 tasks

12 - 算法 II #12

Linjiayu6 opened this issue Jul 13, 2020 · 13 comments

Comments

@Linjiayu6
Copy link
Owner

Linjiayu6 commented Jul 13, 2020

@Linjiayu6 Linjiayu6 changed the title 面试鸡精汇总 12 - 算法 II Jul 14, 2020
@Linjiayu6
Copy link
Owner Author

Linjiayu6 commented Jul 14, 2020

一. 数组

- [栈] push / pop
- [队列] unshift(增加) / shift(从头推出)
- [截取] (返回操作后的值, 原值不改变) arr.slice(start, end) eg:slice(1, 3) 只是 1, 2
- [增加] splice arr.splice(index, 0, va;1, val2, ....) 会改变原数组
- [删除] splice arr.splice(index, delnum) 从哪儿开始 删除几个
- [过滤] [19, 2, 5].filter(d => d > 10) 最后是[19]
- [过滤+是否包含]  [19, 2, 5].filter(d => [2, 3].includes(d))  最后是[2]

交集的一定都要用 filter + includes + splice + indexOf

@Linjiayu6
Copy link
Owner Author

Linjiayu6 commented Jul 19, 2020

2 - 链表

@Linjiayu6
Copy link
Owner Author

Linjiayu6 commented Jul 19, 2020

3 - 字符串

@Linjiayu6
Copy link
Owner Author

Linjiayu6 commented Jul 19, 2020

4 - 栈

@Linjiayu6
Copy link
Owner Author

Linjiayu6 commented Jul 19, 2020

5 - 队列

@Linjiayu6
Copy link
Owner Author

Linjiayu6 commented Jul 19, 2020

6 - 哈希表

@Linjiayu6
Copy link
Owner Author

Linjiayu6 commented Jul 19, 2020

@Linjiayu6
Copy link
Owner Author

Linjiayu6 commented Jul 19, 2020

8 - 堆 🔥🔥🔥🔥🔥

@Linjiayu6
Copy link
Owner Author

Linjiayu6 commented Jul 19, 2020

@Linjiayu6
Copy link
Owner Author

Linjiayu6 commented Jul 19, 2020

10 - 排序算法

  1. 快速: 中间位置的值 pivot, left 小于 pivot, right 大于 pivot (时间复杂度 最好 nlogn 最差 n^2 平均nlogn)
  2. 归并: 大问题拆分 局部有序排序 最后 结合在一起 (时间复杂度 最好 nlogn 最差 nlogn 平均nlogn)
  3. 冒泡: 从下往上 冒泡, 每次找的都是未排序的最大值 (时间复杂度 最好 n 最差 n^2 平均n^2)
  4. 插入: 后面往前面插入 前面有序 (时间复杂度 最好 n 最差 n^2 平均n^2)
  5. 桶: 先分组, 再排序 (先求数组的最大值和最小值,得知了分组的范围,需要确认分多少个桶,再针对桶内部进行排序)
  6. 选择: 从第一个i 位置开始, j = i + 1, 往后面去找最小的,和i位置交换。每次选择最小的交换。 (时间复杂度 最好 n^2 最差 n^2 平均n^2)
  7. shell

@Linjiayu6
Copy link
Owner Author

Linjiayu6 commented Jul 19, 2020

12 - 其他编程题

@Linjiayu6
Copy link
Owner Author

Linjiayu6 commented Jul 29, 2020

13 - 动态规划

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

1 participant