GuessWhoIam
GuessWhoIam
全部文章
题解
面试(1)
归档
标签
去牛客网
登录
/
注册
GuessWhoIam的博客
全部文章
/ 题解
(共27篇)
题解 | #整数中1出现的次数(从1到n整数中1出现的次数)#
# -*- coding:utf-8 -*- class Solution: def checkNum(self,x): num=0 ...
剑指offer
2021-08-30
0
212
题解 | #求1+2+3+...+n#
-- coding:utf-8 -- class Solution: def Sum_Solution(self, n): if n==1: return 1 return n+self.Sum_Solution(n-1) # write c...
剑指offer
2021-08-30
0
212
题解 | #把字符串转换成整数#
1)普通的进行遍历判断的方法。这道题只要是边界用例比较多,要考虑全面。 # -*- coding:utf-8 -*- class Solution: def StrToInt(self, ...
剑指offer
2021-08-30
0
287
题解 | #树的子结构#
用递归来做: # -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # ...
剑指offer
二叉树
2021-08-30
0
225
题解 | #数组中只出现一次的两个数字#
class Solution: def FindNumsAppearOnce(self , array ): &nbs...
剑指offer
位运算
2021-08-29
0
207
题解 | #机器人的运动范围#
# -*- coding:utf-8 -*- def canGet(matrix,i,j,rows,cols,thre): res=int(i/10)+i%1...
剑指offer
回溯法
2021-08-28
0
271
题解 | #最小的K个数#
用回溯法(DFS 深度搜索)做: 记得要用一种方式标注已被访问的位置,若在此点找不到路径,要记得把访问状态改回去!!! # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param matrix&nbs...
剑指offer
回溯法
2021-08-28
0
242
题解 | #最小的K个数#
用快速排序法做: # -*- coding:utf-8 -*- class Solution: def quicksort(self,array): ...
剑指offer
排序
2021-08-28
0
289
题解 | #二叉搜索树与双向链表#
解题步骤: 1)用递归得到二叉搜索树的中序遍历结果并存入列表 order里。注意:这里列表中存的是每个节点而非value 2)遍历列表order并生成双向链表。在这里要注意index=0和len(order)-1时的操作。 边界用例: 二叉树为None或只有一个节点时...
剑指offer
二叉树
2021-08-27
0
253
题解 | #二叉搜索树的后序遍历序列#
# -*- coding:utf-8 -*- def verify(seq): if len(seq)&l...
剑指offer
二叉树
2021-08-25
0
250
首页
上一页
1
2
3
下一页
末页