随笔分类 -  Backtracking

回溯
[Leetcode 22]生成括号generate parentheses
摘要:题目 给定括号对数n,生成所有可能的标准括号结果* *指不能)( https://leetcode.com/problems/generate-parentheses/ Given n pairs of parentheses, write a function to generate all co 阅读全文
posted @ 2021-12-05 06:47 alau 阅读(39) 评论(0) 推荐(0)
[Leetcode 701]二叉搜索树BST中插入元素
摘要:题目 BST二叉搜索树中插入元素 二叉搜索树:左边<root<右边 https://leetcode.com/problems/insert-into-a-binary-search-tree/ You are given the root node of a binary search tree 阅读全文
posted @ 2021-12-04 08:10 alau 阅读(73) 评论(0) 推荐(0)
[Leetcode 235/236]LCA二叉树最近公共祖先Lowest Common Ancestor of a Binary Tree
摘要:题目 给定二叉树和两个点,求两点的LCA最近公共祖先 Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of L 阅读全文
posted @ 2021-12-04 02:54 alau 阅读(56) 评论(0) 推荐(0)
[Leetcode 98]判断有效的二叉搜索树Validate Binary Search Tree
摘要:题目 https://leetcode.com/problems/validate-binary-search-tree 判断所给二叉树是否是二叉搜索树 二叉搜索树:其值left<root<right *[2,2,2]这种相等的情况也不是搜索树 Given the root of a binary 阅读全文
posted @ 2021-12-03 23:41 alau 阅读(48) 评论(0) 推荐(0)
[Leetcode 40]组合数和II Combination Sum II
摘要:【题目】 Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate 阅读全文
posted @ 2018-11-30 22:27 alau 阅读(173) 评论(0) 推荐(0)
[Leetcode 39]组合数的和Combination Sum
摘要:【题目】 Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where 阅读全文
posted @ 2018-11-30 22:10 alau 阅读(157) 评论(0) 推荐(0)
[Leetcode 216]求给定和的数集合 Combination Sum III
摘要:【题目】 Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination shoul 阅读全文
posted @ 2018-11-26 20:22 alau 阅读(262) 评论(0) 推荐(0)
[Leetcode 37]*数独游戏 Sudoku Solver 附解释
摘要:【题目】 每一行、每一列、每个3*3的格子里只能出现一次1~9。 【思路】 参考了思路,附加了解释。 dfs遍历所有非空格子,n是已经填好的个数。 初始化条件。n=81,都填了,返回结束。对于已经填好的b[x][y] != '.'跳过,到下一个。 xy的设计保证先行后列填写。 开始填数字,valid 阅读全文
posted @ 2018-11-19 16:29 alau 阅读(179) 评论(0) 推荐(0)
[Leetcode 90]求含有重复数的子集 Subset II
摘要:【题目】 Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not 阅读全文
posted @ 2018-11-17 22:52 alau 阅读(208) 评论(0) 推荐(0)
[Leetcode 78]求子集 Subset
摘要:【题目】 Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. 求 阅读全文
posted @ 2018-11-17 22:41 alau 阅读(311) 评论(0) 推荐(0)