题目: Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to reach the last index in the minimum number of j…
题目: Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions. 就是让你输出N皇后问题的解法数目. 直接求解,每次还记录整个棋盘位置那种方法就不说了,必须超时. 有一个牛逼大了的超级无敌帅的位移动解法.我们暂且不表.看看我当时想的一个解法. 首先,对于皇后的那个递归方法,我有三个变量分别表示1.一个int…
题目:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example,S = "ADOBECODEBANC"T = "ABC" Minimum window is "BANC". Note:If there is no such windo…
题目: Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area. leetcode的题目真是越来越经典了.比如这个题目,就是一道男默女泪的题. 一般人拿到这个题目,除非做过类似的,很难一眼找出一个方法来,更别说找一个比较优化的方法了. 首先一个难点就是,你怎么判断某个区域就是一个矩形呢? 其次,以何种方式来遍历这个2D的…
题目 Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to reach the last index in the minimum number of ju…
题目:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. You may not alter the values in the nodes, only…
题目:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example,S = "ADOBECODEBANC"T = "ABC" Minimum window is "BANC". Note:If there is no such windo…
题目: Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, S = "ADOBECODEBANC" T = "ABC" Minimum window is "BANC". Note: If there is no such w…
题目:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. Follow up: Did you use extra space?A straight forward solution using O(mn) space is probably a bad idea.A simple improvement uses O(m + n) space, but sti…
题目:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example,  Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6. 例如给出上图中的黑色部分(数组表示),让你求出蓝色部分. 这也是个神题...当…