LeetCode
neostar2008
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode Combination Sum
Good Article: http://blog.youkuaiyun.com/zyfo2/article/details/8592955转载 2013-05-05 07:18:09 · 478 阅读 · 0 评论 -
leetcode valid panlidrome
public class Solution { public boolean isPalindrome(String s) { // Start typing your Java solution below if(s.length() == 1 || s.length() == 0 ) return true; Strin原创 2013-10-02 11:29:37 · 809 阅读 · 0 评论 -
leetcode add binary
public String addBinary(String a, String b) { // char resi = '0'; int lena = a.length(); int lenb = b.length(); int len = (lena > lenb ? lena : lenb) - 1; int i原创 2013-09-12 02:27:20 · 563 阅读 · 0 评论 -
Leetcode Climbing Stairs
public int climbStairs(int n) { // Start typing your Java solution below // DO NOT write main() function if(n == 0) return 0; if(n == 1) return 1; int[] arr = new原创 2013-09-12 04:51:08 · 695 阅读 · 0 评论 -
leetcode plus one
public int[] plusOne(int[] digits) { if(digits.length < 1) return null; String ans = ""; int resi = 0; for(int i = digits.length - 1; i>=0; i--) { int cu原创 2013-09-12 04:37:33 · 663 阅读 · 0 评论 -
leetcode minimum path sum
DPMin[ i, j] = Min( Min[i - 1][j] + grid[i][j], Min[i][j - 1] + grid[ i ][ j ]); public int minPathSum(int[][] grid) { // Start typing your Java solution below [[1]] //原创 2013-09-11 08:12:44 · 443 阅读 · 0 评论 -
leetcode merge two sorted list
public ListNode mergeTwoLists(ListNode l1, ListNode l2) { // Start typing your Java solution below // DO NOT write main() function ListNode ans = new ListNode(0); ListNode he原创 2013-09-11 08:30:26 · 448 阅读 · 0 评论 -
leetcode length of last word
public class LastWordLength { public int lengthOfLastWord(String s) { // if(s == null || s.length() == 0 ) return 0; s = s.trim(); s = s.replaceAll("[ ]+", " ");原创 2013-08-13 05:47:46 · 458 阅读 · 0 评论 -
leetcode insert interval
Iterate the intervals list. Compare newInterval with each item in the list. If overlapping, update the item. Otherwise(no overlapping), add newInterval into list. Then delete duplicates or merge overl原创 2013-07-26 08:45:15 · 470 阅读 · 0 评论 -
leetcode merge intervals
import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;class Interval { int start; int end; Interval() {start = 0; end = 0;} Interval(int s, int e) {start = s; end原创 2013-07-25 05:28:22 · 522 阅读 · 0 评论 -
leetcode spiral matrix
public ArrayList spiralOrder(int[][] matrix) { // ArrayList result = new ArrayList(); if(matrix == null) return result; if(matrix.length < 1) return result;原创 2013-07-20 08:13:23 · 422 阅读 · 0 评论 -
leetcode Jump Game
/* Leetcode JumpGameGiven 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 posi原创 2013-07-20 08:26:53 · 482 阅读 · 0 评论 -
leetcode maxSubArray
O(n) solutionpublic class MaxSubArray { public int maxSubArray(int[] A) { int sum = 0, curr = 0; int max = Integer.MIN_VALUE; for(curr = 0; curr < A.length; curr++) {原创 2013-07-18 02:14:50 · 528 阅读 · 0 评论 -
leetcode pow
public class Pow {// //recursive version// //stack overflow when n is large// public double pow(double x, int n) {// // if(n < 0) {// return 1.0/pow(x, -n);// }// /原创 2013-07-17 02:58:08 · 497 阅读 · 0 评论 -
Leetcode Permutation II
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1原创 2013-07-16 07:56:00 · 479 阅读 · 0 评论 -
leetcode anagrams
import java.util.ArrayList;import java.util.Arrays;import java.util.HashMap;/* * Given an array of strings, return all groups of strings that are anagrams. * Note: All inputs will be in lower-c原创 2013-07-16 08:34:35 · 459 阅读 · 0 评论 -
leetcode edit distance
public int minDistance(String word1, String word2) { // int rowNum = word1.length(); int colNum = word2.length(); int[][] dist = new int[rowNum + 1][colNum + 1]; for转载 2013-09-20 07:47:34 · 593 阅读 · 0 评论
分享