leetcode_oj
文章平均质量分 69
pandagong
这个作者很懒,什么都没留下…
展开
-
Single Number(c++)
Single Number Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implemen原创 2014-04-17 18:45:07 · 527 阅读 · 0 评论 -
Binary Tree Preorder Traversal
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { publi原创 2014-09-11 23:45:37 · 301 阅读 · 0 评论 -
Binary Tree Postorder Traversal
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { publi原创 2014-09-12 09:58:30 · 354 阅读 · 0 评论 -
Best Time to Buy and Sell Stock
public class Solution { public int maxProfit(int[] prices) { int profit = 0; if(null == prices || prices.length < 1) return profit; for(int i=0; i<prices.length原创 2014-09-11 13:48:33 · 314 阅读 · 0 评论 -
Binary Tree Inorder Traversal
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { publi原创 2014-09-12 00:04:00 · 318 阅读 · 0 评论 -
Best Time to Buy and Sell Stock II
public class Solution { public int maxProfit(int[] prices) { int profit = 0; if (null == prices || prices.length == 0) return profit; int hold = prices[0];原创 2014-09-11 13:35:00 · 254 阅读 · 0 评论 -
Same Tree
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { publi原创 2014-09-10 14:31:09 · 216 阅读 · 0 评论 -
Reverse Integer
public class Solution { public int reverse(int x) { int result = 0; int temp = Math.abs(x); while(temp != 0){ result =result * 10 + temp % 10; temp原创 2014-09-10 15:19:24 · 273 阅读 · 0 评论 -
Maximum Depth of Binary Tree
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { publi原创 2014-09-10 13:57:21 · 219 阅读 · 0 评论 -
Single Number
public class Solution { public int singleNumber(int[] A) { int result = 0; for(int i=0; i<A.length; i++){ result = result ^ A[i]; } return result; }原创 2014-09-10 13:25:26 · 240 阅读 · 0 评论 -
Balanced Binary Tree
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { priva原创 2014-09-12 23:07:33 · 301 阅读 · 0 评论