陈文泰
陈文泰
全部文章
分类
题解(65)
归档
标签
去牛客网
登录
/
注册
White Wolf
Geralt
全部文章
(共65篇)
题解 | #跳台阶#
# -*- coding:utf-8 -*- class Solution: def jumpFloor(self, number): # write code here n = number if n <=2: ...
2021-07-14
0
315
题解 | #用两个stack实现队列#
push:直接s1.append()pop:若s2为空,则需要把s1中的元素pop到s2里;若s2不是空,则直接s2.pop # -*- coding:utf-8 -*- class Solution: def __init__(self): self.stack1 = []...
2021-07-14
0
286
题解 | #寻找第K大#
注意,这里判断p==k不是p+1==k. 第K大 -> 第n-K+1小 如n=6,a = [1,2,3,4,5,6],第2大的数是5,第4小的数是4,第5小的数才对应5.而partition返回的p -> 有0,...,p-1,一共p个数比nums[p]小,所以nums[p]是第p+1小...
算法
2021-07-13
0
281
题解 | #求二叉树的层序遍历#
用deque数据结构 from collections import deque class Solution: def levelOrder(self , root ): # write code here if not root: ...
2021-07-13
0
365
题解 | #最小的K个数#
快速选择算法(quick select)参考:https://mp.weixin.qq.com/s/TRO3FOKT90Mpvn3hQWVBAQ # -*- coding:utf-8 -*- class Solution: def GetLeastNumbers_Solution(self,...
算法
2021-07-13
0
346
首页
上一页
1
2
3
4
5
6
7
下一页
末页