摘要: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 maxim
阅读全文
摘要:You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb...
阅读全文
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple
阅读全文
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple
阅读全文
摘要:Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction
阅读全文
摘要:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"tw...
阅读全文
摘要:The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order,We get the following sequence
阅读全文
摘要: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.
阅读全文
摘要:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist
阅读全文
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.思路:例如0110111010011101111011111000...
阅读全文
摘要:There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it cost
阅读全文
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4,−1,2,
阅读全文
摘要:Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled wit
阅读全文
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character '.'. You may assume that there will be
阅读全文
摘要:Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions.
阅读全文
摘要: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
阅读全文
摘要:Implement wildcard pattern matching with support for '?' and '*'. *正则表达式的定义: '.' Matches any single character. '*' Matches zero or more of the precedi
阅读全文
摘要:Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given "25525511135", return ["2
阅读全文
摘要: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 num
阅读全文
摘要: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 repeat
阅读全文