腻o
腻o
全部文章
分类
题解(5)
归档
标签
去牛客网
登录
/
注册
腻o的博客
全部文章
(共3篇)
DFS解决岛屿问题
labuladong大佬的python版本,推荐大嘎关注公众号。 二维矩阵的DFS代码框架 def dfs(self,grid,i,j,visited:bool): m, n =len(grid), len(grid[0]) # 越界条件 if...
回溯
2022-05-08
1
682
题解 | #加起来和为目标值的组合#
用回溯法解决目标值组合问题 一、NC238 加起来和为目标值的组合 class Solution: def combinationCount(self , target: int, nums: List[int]) -> List[List[int]]: # write...
Python3
回溯
2022-05-07
0
425
题解 | 回溯法解决排列组合问题 #一、集合的所有子集(一) #
回溯法解决排列组合问题 模板 result=[] def dfs(路径,选择列表): if 满足结束条件: result.append(路径) return for 选择 in 选择列表: 做选择 dfs(路径,选择列表) 撤销选择 一、NC27 集合的所有子集(一) 子集...
Python3
回溯
2022-05-06
0
429