描述
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 com
...
描述
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 com
...
描述
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 com
...
描述
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 transact
...
描述
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 ma
...
描述
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 ma
...
描述
Implement int sqrt(int x).
Compute and return the square root of x.
分析二分查找。注意结果要向下取整时返回high。
代码Python12345678910111213141516171819202122class Solu
...
描述
Implement pow(x, n).
分析二分法,递归很简单,迭代有一定技巧。
代码递归1234567891011121314151617class Solution(object): def myPow(self, x, n): """ :type x
...
描述
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 “ad
...
描述
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
...
描述
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
For example, given n = 3, a solution set is
...
描述
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
...
描述
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
...
描述
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 rep
...
描述
Given a string containing only digits, restore it by returning all possible valid IP address combinations.
For example:Given “25525511135”,
return
...