随笔分类 - Backtracking
回溯
[Leetcode 22]生成括号generate parentheses
摘要:题目 给定括号对数n,生成所有可能的标准括号结果* *指不能)( https://leetcode.com/problems/generate-parentheses/ Given n pairs of parentheses, write a function to generate all co
阅读全文
[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
阅读全文
[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
阅读全文
[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
阅读全文
[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
阅读全文
[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
阅读全文
[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
阅读全文
[Leetcode 37]*数独游戏 Sudoku Solver 附解释
摘要:【题目】 每一行、每一列、每个3*3的格子里只能出现一次1~9。 【思路】 参考了思路,附加了解释。 dfs遍历所有非空格子,n是已经填好的个数。 初始化条件。n=81,都填了,返回结束。对于已经填好的b[x][y] != '.'跳过,到下一个。 xy的设计保证先行后列填写。 开始填数字,valid
阅读全文
[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
阅读全文
[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. 求
阅读全文
浙公网安备 33010602011771号