backtraking
文章平均质量分 74
二喵棒棒哒
算法 大数据 区块链 硕士在读
github:https://github.com/zslomo
展开
-
Combination Sum题解
题干: Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited number原创 2016-02-01 22:46:21 · 476 阅读 · 0 评论 -
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 sol原创 2016-02-06 00:26:46 · 806 阅读 · 0 评论 -
Combination Sum II 题解
题目:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be used once in the combinatio原创 2016-02-06 18:18:51 · 465 阅读 · 0 评论 -
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 should be a unique set of numbers.Ensure that numbers with原创 2016-02-10 13:57:45 · 400 阅读 · 0 评论 -
Word Search 题解
题目: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原创 2016-02-10 14:26:53 · 557 阅读 · 0 评论 -
Word Search II 题解
题目:Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those hori原创 2016-02-10 15:34:19 · 557 阅读 · 1 评论 -
N-Queens II 经典问题:8皇后问题 题解
题目上一篇我们使用了回溯法,然而提到回溯法就不得不提一个1848年提出的经典题目:8皇后问题,这个问题描述非常简单,一个8*8的棋盘上,放置8个皇后,使得每个皇后都不行相互攻击,既每个皇后的所在行、所在列、所在斜线上都不能有其他皇后,问有多少种解法,题目初看非常像图论问题,实际上也确实是,对图论感兴趣的同学可以去看离散数学的相关内容,这里我们用一种更巧妙也更直观的方法来解决这个问题,那就是——回溯法原创 2016-02-06 00:15:24 · 2763 阅读 · 0 评论