已注销
已注销
全部文章
题解
归档
标签
去牛客网
登录
/
注册
已注销的博客
全部文章
/ 题解
(共7篇)
题解 | #调整数组顺序使奇数位于偶数前面(二)#
就是lambda表达式 import functools class Solution: def reOrderArrayTwo(self , array: List[int]) -> List[int]: f = lambda x,y:1 if not x%2 els...
Python3
2022-04-17
1
0
题解 | #链表的中间结点#
快慢指针 不要边界判断,直接异常梭哈 # class ListNode: # def __init__(self, x): # self.val = x # self.next = None # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法...
Python3
2022-04-07
0
0
题解 | #链表中环的入口结点#
快慢指针 不要边界判断了,就用异常 class Solution: def EntryNodeOfLoop(self, pHead): if not pHead.next:return pHead.next fast,slow = pHead,pHead ...
Python3
2022-04-07
0
0
题解 | #二叉树的深度#
使用双端队列,层次遍历 # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # # 代码中的类名、方法...
Python3
2022-04-04
0
0
题解 | #对称的二叉树#
使用中序遍历,如果是对称的,遍历结果一定是对称的,且结点个数一定是奇数个,再排除根结点下左右子树值不相等的情况即可 class Solution: def isSymmetrical(self , pRoot: TreeNode) -> bool: #空树对称 ...
Python3
2022-04-03
0
0
题解 | #二叉搜索树的第k个节点#
什么是二叉搜索树? 定义:二叉查找树,又被称为二叉搜索树。其特点如下:设x为二叉查找树中的一个结点,x节点包含关键字key,一句话就是左孩子比父节点小,右孩子比父节点大,还有一个特性就是”中序遍历“可以让结点有序。 可以看出,在二叉树中: 若任意节点的左子树不空,则左子树上所有结点的值均小于它的...
Python3
栈
2022-03-29
0
0
题解 | #复杂链表的复制#
”接头霸王“ 来个不正经的题解 class Solution: # 返回 RandomListNode def Clone(self, pHead): # write code here if not pHead: return...
Python3
2022-03-29
0
0