自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(15)
  • 收藏
  • 关注

原创 206. Reverse Linked List

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

2016-03-01 14:51:39 181

原创 52. N-Queens II

public class Solution { private final static Set occupiedCols = new HashSet(); private final static Set occupiedDiag1s = new HashSet(); private final static Set occupiedDiag2s = new HashSet();

2016-03-01 14:17:23 222

原创 144. Binary Tree Preorder Traversal

/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution {

2016-02-29 10:07:21 156

原创 318. Maximum Product of Word Lengths

public class Solution { public int maxProduct(String[] words) { int max = 0 ; int[] masks = new int[words.length]; for (int i = 0; i < masks.length; i++) { for (char c :

2016-02-29 09:39:00 168

原创 268. Missing Number

public class Solution { public int missingNumber(int[] nums) { int[] copy = new int[nums.length+1]; copy[0] = 1; for (int i = 0; i < nums.length; i++) { copy[nums[i]] =

2016-02-26 14:47:01 162

原创 169. Majority Element

public class Solution { public int majorityElement(int[] nums) { HashMap elementNum = new HashMap(nums.length/2); for (int element : nums) { if (elementNum.containsKey(element

2016-02-25 19:03:29 158

原创 217. Contains Duplicate

解法一:public class Solution { public boolean containsDuplicate(int[] nums) { HashSet hasSet = new HashSet<>(); for (int i = 0; i < nums.length; i++) { if (hasSet.contains(nums[i

2016-02-25 10:00:13 141

原创 171. Excel Sheet Column Number

public class Solution { public int titleToNumber(String s) { String _27String = s.toLowerCase(); int res = 0; for (int i = 0; i < _27String.length(); i++) { res = (i

2016-02-25 09:24:16 149

原创 122. Best Time to Buy and Sell Stock II

解法一: public class Solution { public int maxProfit(int[] prices) { if (prices.length<2) return 0; int sumProfit = 0,startIndex = 0; for (int i = 1; i < prices.length; i++) {

2016-02-25 08:57:23 168

原创 238. Product of Array Except Self

解法一: public class Solution { public int[] productExceptSelf(int[] nums) { int product=1,zeroNum = 0; int res[] = new int[nums.length]; for (int i : nums) { if (i!=0) { product*=

2016-02-24 10:09:12 255

原创 260. Single Number III

解法一: public class Solution { public int[] singleNumber(int[] nums) { int[] copyNum = new int[nums.length]; LinkedList list = new LinkedList(); for (int i : nums) { if (list.cont

2016-02-24 08:53:15 193

原创 100. Same Tree

解法一: public class solution { public boolean isSameTree(TreeNode p, TreeNode q) { if (p==null&&q==null) { return true; } if (p==null&&q!=null) { return f

2016-02-23 12:40:06 179

原创 226. Invert Binary Tree

解法一: public TreeNode invertTree(TreeNode root) { ArrayDeque queue = new ArrayDeque(); queue.add(root); while (!queue.isEmpty()) { TreeNode temp1 = queue.pollFirst(); TreeNode temp2 = t

2016-02-23 11:00:11 192

原创 237. Delete Node in a Linked List

public void deleteNode(ListNode node) { node.val = node.next.val; node.next=node.next.next; }

2016-02-23 10:58:56 236

原创 283. Move Zeroes

解法一:public void moveZeroes(int[] nums) { if (nums.length==1) { return; } int zeroNum=0; for (int i = 0; i < nums.length-zeroNum; i++) { if (nums[i]==0) { for (int j =

2016-02-23 10:53:39 152

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

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