陈文泰
陈文泰
全部文章
分类
题解(65)
归档
标签
去牛客网
登录
/
注册
White Wolf
Geralt
全部文章
(共65篇)
题解 | #判断回文#
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # @param str string字符串 待判断的字符串 # @return bool布尔型 # class Solution: def judge(self , str ): # w...
2021-07-18
0
264
题解 | #二叉树的最大深度#
bfs, from collections import deque # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.rig...
2021-07-18
0
391
题解 | #岛屿数量#
dfs,走过的标0 # # 判断岛屿数量 # @param grid char字符型二维数组 # @return int整型 # class Solution: def solve(self , grid ): # write code here m = l...
2021-07-18
0
324
题解 | #输出二叉树的右视图#
先重建二叉树,再用层次遍历打印右视图 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # 求二叉树的右视图 # @param xianxu int整型一维数组 先序遍历 # @param zhongxu int整型一维数组 中序遍历 # @return int整型一...
2021-07-18
0
334
题解 | #接雨水问题#
双指针往中间移动,若lmax>rmax则hi--,否则lo++ # # max water # @param arr int整型一维数组 the array # @return long长整型 # class Solution: def maxWater(self , arr ): ...
2021-07-17
0
319
题解 | #字符串的排列#
回溯,用set去重 # -*- coding:utf-8 -*- from collections import Counter class Solution: def Permutation(self, ss): # write code here arr ...
2021-07-17
0
267
题解 | #合并k个已排序的链表#
优先队列,队列里存放(node.val, node)的pair # class ListNode: # def __init__(self, x): # self.val = x # self.next = None # # # @param lists ...
2021-07-16
0
315
题解 | #求平方根#
二分查找 # # # @param x int整型 # @return int整型 # class Solution: def sqrt(self , x ): # write code here if x <= 1: ret...
2021-07-16
0
304
题解 | #三数之和#
# # # @param num int整型一维数组 # @return int整型二维数组 # class Solution: def threeSum(self , num ): # write code here def twoSum(num, ta...
2021-07-15
0
290
题解 | #最长回文子串#
注意return hi-lo-1,其实是hi-lo-2+1 # -*- coding:utf-8 -*- class Solution: def getLongestPalindrome(self, A, n): # write code here def ...
2021-07-15
0
242
首页
上一页
1
2
3
4
5
6
7
下一页
末页