摘要: Given a collection of distinct numbers, return all possible permutations. For example,[1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2, 阅读全文
posted @ 2017-02-10 14:55 CodesKiller 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 回溯法 回溯法有“通用的解题法”之称。用它可以系统地搜索一个问题的所有解或任一解。回溯法是一种即带有系统性又带有跳跃性的搜索算法。它在问题的解空间树中,按深度优先策略,从根节点出发搜索解空间树。算法搜索至解空间树的任一结点时,先判断该节点是否包含问题的解。如果不包含,则跳过对以该节点为根的子树的搜索 阅读全文
posted @ 2017-02-10 14:27 CodesKiller 阅读(596) 评论(0) 推荐(0) 编辑
摘要: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib 阅读全文
posted @ 2017-02-10 13:56 CodesKiller 阅读(151) 评论(0) 推荐(0) 编辑
摘要: The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 阅读全文
posted @ 2017-02-10 13:03 CodesKiller 阅读(139) 评论(0) 推荐(0) 编辑
摘要: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. 阅读全文
posted @ 2017-02-10 11:56 CodesKiller 阅读(98) 评论(0) 推荐(0) 编辑
摘要: Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space 阅读全文
posted @ 2017-02-10 11:44 CodesKiller 阅读(129) 评论(0) 推荐(0) 编辑
摘要: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2017-02-10 09:10 CodesKiller 阅读(111) 评论(0) 推荐(0) 编辑
摘要: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the fo 阅读全文
posted @ 2017-02-10 08:50 CodesKiller 阅读(161) 评论(0) 推荐(0) 编辑
摘要: A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its inde 阅读全文
posted @ 2017-02-10 05:48 CodesKiller 阅读(111) 评论(0) 推荐(0) 编辑
摘要: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 这道题和之前的Game of Live有些不一样,区别在于,之前那道题目只有两种状态,即矩阵只有0和1两种,并且 阅读全文
posted @ 2017-02-10 03:36 CodesKiller 阅读(122) 评论(0) 推荐(0) 编辑
摘要: According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John 阅读全文
posted @ 2017-02-10 02:57 CodesKiller 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 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 adja 阅读全文
posted @ 2017-02-10 01:21 CodesKiller 阅读(145) 评论(0) 推荐(0) 编辑