码迷,mamicode.com
首页 >  
搜索关键字:solution upgrade    ( 13024个结果)
[LeetCode] Container With Most Water
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
[LeetCode] Minimum Path Sum
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 Integer
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
Palindrome Number
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
[LeetCode] Permutations
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
Integer to Roman
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
Longest Common Prefix
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
[LeetCode] Unique Paths
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
[LeetCode] Rotate Image
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
LeetCode--Combination Sum
由于需要就地保存清零信息,所以把信息保存在第一行和第一列 1 class Solution { 2 public: 3 void setZeroes(vector > &matrix) { 4 const int ROW = matrix.size(); 5 ...
分类:其他好文   时间:2014-09-06 23:46:04    阅读次数:261
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!