回溯
文章平均质量分 84
介绍回溯的算法思想和题目
memcpy0
希望探索文理结合的自由之路。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode 2698. 求一个整数的惩罚数【字符串,回溯,预处理,打表】1678
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-10-29 16:49:26 · 306 阅读 · 0 评论 -
LeetCode 22. 括号生成【字符串,回溯;动态规划】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-10-24 01:35:58 · 587 阅读 · 0 评论 -
LeetCode 40. Combination Sum II【回溯,剪枝】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-09-14 01:03:05 · 445 阅读 · 0 评论 -
LeetCode 39. Combination Sum【回溯,剪枝】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-09-13 23:43:23 · 716 阅读 · 0 评论 -
LeetCode 1255. Maximum Score Words Formed by Letters【字符串,回溯,状压】
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的。原创 2023-03-01 03:15:43 · 320 阅读 · 0 评论 -
LeetCode 37. Sudoku Solver【回溯/递归/数组】困难
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的仓库:https://github.com/memcpy0/LeetCode-Conqu.原创 2021-10-02 00:35:03 · 466 阅读 · 0 评论 -
LeetCode 1219. Path with Maximum Gold【DFS】中等
In a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty.Return the maximum amount of gold you can collect under the conditions: Every time you are located in a cell you will原创 2021-06-05 02:24:28 · 383 阅读 · 0 评论 -
LeetCode C++ 784. Letter Case Permutation【String/Bit Manipulation/Backtracking】中等
Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string.Return a list of all possible strings we could create. You can return the output in any order.Example 1:Input: S = "a1b2"Output原创 2021-05-05 03:24:17 · 445 阅读 · 0 评论 -
LeetCode C++ 980. Unique Paths III【DFS/Backtracking】困难
On a 2-dimensional grid, there are 4 types of squares: 1 represents the starting square. There is exactly one starting square. 2 represents the ending square. There is exactly one ending square. 0 represents empty squares we can walk .原创 2021-02-17 01:57:54 · 379 阅读 · 0 评论 -
LeetCode C++ 面试题 08.07. Permutation I LCCI【Backtracking/Recursion】中等
Write a method to compute all permutations of a string of unique characters.Example1:Input: S = "qwe"Output: ["qwe", "qew", "wqe", "weq", "ewq", "eqw"]Example2:Input: S = "ab"Output: ["ab", "ba"]Note:All charaters are English letters.1 <= S.原创 2020-11-30 15:10:49 · 480 阅读 · 0 评论 -
LeetCode C++ 面试题 08.12. Eight Queens LCCI【回溯】困难
Write an algorithm to print all ways of arranging n queens on an n x n chess board so that none of them share the same row, column, or diagonal. In this case, “diagonal” means all diagonals, not just the two that bisect the board.Notes: This problem is a原创 2020-11-15 23:04:27 · 379 阅读 · 0 评论 -
LeetCode C++ 52. N-Queens II【回溯】困难
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n , return the number of distinct solutions to the n-queens puzzle.Example:Input: 4Output: 2Explanation: There are原创 2020-10-18 00:13:27 · 322 阅读 · 0 评论 -
LeetCode C++ 797. All Paths From Source to Target【图论/DFS/回溯】中等
Given a directed acyclic graph of N nodes. Find all possible paths from node 0 to node N-1 , and return them in any order.The graph is given as follows: the nodes are 0, 1, ..., graph.length - 1 . graph[i] is a list of all nodes j for which the edge (i,原创 2020-10-02 16:07:39 · 419 阅读 · 0 评论 -
LeetCode C++ 79. Word Search【DFS/Backtracking】中等
Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or vertically neighboring. The same letter cell may not be used more tha原创 2020-09-14 00:54:41 · 441 阅读 · 0 评论 -
LeetCode C++ 51. N-Queens【回溯】困难
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n , return all distinct solutions to the n-queens puzzle.Each solution contains a distinct board configuration of the n原创 2020-09-03 23:56:52 · 389 阅读 · 0 评论 -
LeetCode C++ 491. Increasing Subsequences【DFS】中等
Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing subsequence should be at least 2 .Example:Input: [4, 6, 7, 7]Output: [[4, 6], [4, 7], [4, 6, 7], [4, 6, 7原创 2020-08-27 01:39:04 · 438 阅读 · 0 评论 -
LeetCode C++ 17. Letter Combinations of a Phone Number【DFS/Backtracking】中等
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.Examp原创 2020-08-27 01:24:10 · 591 阅读 · 0 评论 -
LeetCode C++ 44. Wildcard Matching【动态规划/回溯】困难
Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover the entire i原创 2020-07-09 14:09:11 · 570 阅读 · 0 评论
分享