public class Solution { public int maxArea(int[] height) { int len = height.length, low = 0, high = len - 1; int area = 0; whi...
分类:
其他好文 时间:
2014-09-07 23:40:15
阅读次数:
233
public class Solution { public int minPathSum(int[][] grid) { int [][] result = new int[grid.length][grid[0].length]; result[...
分类:
其他好文 时间:
2014-09-07 23:38:45
阅读次数:
231
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321思路: 1 class Solution { 2 public: 3 int reverse( int x ) {...
分类:
其他好文 时间:
2014-09-07 21:08:25
阅读次数:
235
Determine whether an integer is a palindrome. Do this without extra space.思路:先找出x的有效最高位,然后从两侧依次比较最高位和最低位即可。 1 class Solution { 2 public: 3 bool is...
分类:
其他好文 时间:
2014-09-07 20:57:25
阅读次数:
206
1 public class Solution { 2 public List> permute(int[] num) { 3 List> result = new ArrayList>(); 4 permute(result, num, 0); 5 ...
分类:
其他好文 时间:
2014-09-07 17:17:15
阅读次数:
164
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.思路: 1 class Solution { 2 public: 3 strin...
分类:
其他好文 时间:
2014-09-07 17:13:15
阅读次数:
199
Write a function to find the longest common prefix string amongst an array of strings.思路:依次比较即可。 1 class Solution { 2 public: 3 string longestComm...
分类:
其他好文 时间:
2014-09-07 14:46:45
阅读次数:
150
public class Solution { public int uniquePaths(int m, int n) { int [][] result = new int[m][n]; for (int i=0; i<m; i++) { ...
分类:
其他好文 时间:
2014-09-07 14:42:25
阅读次数:
181
public class Solution { public void rotate(int[][] matrix) { int n=matrix.length; for (int i=0; i<n/2; i++) { for (int j=i...
分类:
其他好文 时间:
2014-09-07 14:42:05
阅读次数:
159
由于需要就地保存清零信息,所以把信息保存在第一行和第一列 1 class Solution { 2 public: 3 void setZeroes(vector > &matrix) { 4 const int ROW = matrix.size(); 5 ...
分类:
其他好文 时间:
2014-09-06 23:46:04
阅读次数:
261