xinglu31的专栏

xinglu的个人博客,好记性不如烂笔头

Minimum Depth of Binary Tree

/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { va...

2014-05-20 11:39:58

阅读数 441

评论数 0

Longest Common Prefix

public class Solution { public String longestCommonPrefix(String[] strs) { int len = strs.length; if(len == 0){ return "&am...

2014-05-20 10:20:19

阅读数 393

评论数 0

Sum Root to Leaf Numbers

/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { va...

2014-05-20 09:42:06

阅读数 375

评论数 0

Binary Tree Level Order Traversal

/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { va...

2014-05-15 20:20:07

阅读数 428

评论数 0

Longest Consecutive Sequence

public class Solution { public int longestConsecutive(int[] num) { Arrays.sort(num); int count = 1; int res = 1; int tmp = 0 ; in...

2014-05-15 20:10:46

阅读数 397

评论数 0

Plus One

public class Solution { public int[] plusOne(int[] A) { if(A.length >= 1) { int[] B = new int[A.length + 1]; int added...

2014-05-14 19:31:29

阅读数 399

评论数 0

Single Number II

public class Solution { public int singleNumber(int[] A) { Arrays.sort(A); // for(int i = 0 ; i < A.length ; i++){ // ...

2014-05-14 13:59:39

阅读数 439

评论数 0

Remove Duplicates from Sorted Array II

public class Solution { public int removeDuplicates(int[] A) { int count = 0; int tmp = 0; if(A == null || A.length == 0)...

2014-05-12 16:56:30

阅读数 386

评论数 0

Remove Duplicates from Sorted List

/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = ...

2014-05-12 15:16:20

阅读数 584

评论数 0

Remove Duplicates from Sorted Array

Remove Duplicates from Sorted Arraypublic class Solution { public int removeDuplicates(int[] A) { boolean isEqual = false; int c...

2014-05-12 09:03:53

阅读数 407

评论数 0

Convert Sorted Array to Binary Search Tree

/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { va...

2014-05-06 18:59:05

阅读数 379

评论数 0

Binary Tree Level Order Traversal II

/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { va...

2014-05-06 18:57:09

阅读数 627

评论数 0

Length of Last Word

public class Solution { public int lengthOfLastWord(String s) { int res = 0; if(s.length() == 0){ return res; ...

2014-05-06 09:02:53

阅读数 356

评论数 0

Balanced Binary Tree

public class Solution { public boolean isBalanced(TreeNode root) { if(root == null){ return true; } int depth ...

2014-05-05 20:03:21

阅读数 519

评论数 0

Binary Tree Traversal

Binary Tree Preorder Traversal

2014-05-05 19:27:08

阅读数 358

评论数 0

Maximum Subarray

public class Solution { public int maxSubArray(int[] A) { int res = 0; if(A.length == 0){ return res; } ...

2014-05-04 17:24:38

阅读数 338

评论数 0

Pow(x, n)

public class Solution { public double pow(double x, int n) { double res = 1; if(n == 0){ return res; }else if...

2014-05-04 16:12:31

阅读数 415

评论数 0

提示
确定要删除当前文章?
取消 删除
关闭
关闭