勇敢牛牛生活灿烂
勇敢牛牛生活灿烂
全部文章
题解
归档
标签
去牛客网
登录
/
注册
勇敢牛牛生活灿烂的博客
全部文章
/ 题解
(共16篇)
题解 | #最长上升子序列(一)#
class Solution: def LIS(self , arr: List[int]) -> int: # write code here # dp[i]表示包含底i个元素的最大上升子序列的长度 if not arr: ...
Python3
动态规划
一位数组
2022-05-05
2
358
题解 | #寻找峰值#
直接查找 class Solution: def findPeakElement(self , nums: List[int]) -> int: # write code here l = len(nums) index = 0 ...
Python3
2022-03-31
1
237
题解 | #二维数组中的查找#
直接搜索,可以ac,后续再探索时间复杂度更小的方案 class Solution: def Find(self , target: int, array: List[List[int]]) -> bool: # write code here m, n ...
Python3
2022-03-31
0
246
题解 | #删除有序链表中重复的元素-I#
# class ListNode: # def __init__(self, x): # self.val = x # self.next = None # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @para...
Python3
2022-03-29
1
337
题解 | #按之字形顺序打印二叉树#
是二叉树层序遍历的应用,基础代码和二叉树的层序遍历一致,用了广度优先搜索算法(bfs),详细解答可见我对层序遍历的解答,与层序遍历的区别在于在得到了层序遍历的输出以后,对于其中的奇数层对应的数组进行翻转。需要注意的是,在得到的结果进行翻转更方便,在bfs进行翻转较难理解,容易出错。 # class ...
Python3
2022-03-23
0
267
题解 | #求二叉树的层序遍历#
class Solution: def levelOrder(self , root: TreeNode) -> List[List[int]]: # write code here if not root: return [] ...
Python3
2022-03-23
1
288
首页
上一页
1
2
下一页
末页