- 博客(19)
- 资源 (3)
- 收藏
- 关注
原创 LeetCode 398. Random Pick Index
public class Solution { Map map; Random random; public Solution(int[] nums) { map = new HashMap(); random = new Random(); for (int i = 0; i < nums.length; i++) { if (ma
2017-01-20 22:08:15 199
原创 LeetCode 435. Non-overlapping Intervals
/** * Definition for an interval. * public class Interval { * int start; * int end; * Interval() { start = 0; end = 0; } * Interval(int s, int e) { start = s; end = e; } * } */
2017-01-16 21:14:36 241
原创 LeetCode 137. Single Number II
public class Solution { public int singleNumber(int[] nums) { int r = 0; for (int i = 0; i < 32; i++) { int bit = 1 << i; int sum = 0; for (int j = 0; j
2017-01-15 22:22:09 205
原创 LeetCode 394. Decode String
public class Solution { public String decodeString(String s) { int start = 0; int end = 0; int repeat = 0; int brackets = 0; StringBuilder sb = new StringBu
2017-01-15 21:59:52 242
原创 LeetCode 108. Convert Sorted Array to Binary Search Tree
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution {
2017-01-12 20:17:29 302
原创 LeetCode 46. Permutations
public class Solution { public List> permute(int[] nums) { List> list = new ArrayList>(); int len = nums.length; if (len == 1) { List l = new ArrayList();
2017-01-12 19:38:23 211
原创 LeetCode 337. House Robber III
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution {
2017-01-09 20:46:38 270
原创 LeetCode 328. Odd Even Linked List
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ public class Solution { public ListNode oddE
2017-01-08 19:33:14 223
原创 LeetCode 22. Generate Parentheses
public class Solution { public List generateParenthesis(int n) { List list = new ArrayList(); Map map = new HashMap(); map.put("", 0); for (int i = 0; i < n * 2; i++) {
2017-01-05 21:50:15 301
原创 LeetCode 216. Combination Sum III
public class Solution { public List<List<Integer>> combinationSum3(int k, int n) { return findNum(k, 1, n); } private List<List<Integer>> findNum(int k, int start, int n) { if (start > n) return null; List<List<Integer>>
2017-01-05 20:18:28 221
原创 LeetCode 319. Bulb Switcher
public class Solution { public int bulbSwitch(int n) { return (int)Math.sqrt(n); } }
2017-01-04 21:15:44 218
原创 LeetCode 230. Kth Smallest Element in a BST
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution {
2017-01-03 21:19:56 235
原创 LeetCode 423. Reconstruct Original Digits from English
public class Solution { public String originalDigits(String s) { int[] digits = new int[10]; for (int i = 0; i < s.length(); i++) { switch(s.charAt(i)) { case 'z'
2017-01-03 20:34:13 280
原创 LeetCode 318. Maximum Product of Word Lengths
public class Solution { public int maxProduct(String[] words) { int max = 0; int l = words.length; int[] values = new int[l]; for (int i = 0; i < l; i++) {
2017-01-02 19:51:54 285
原创 LeetCode 454. 4Sum II
public class Solution { public int fourSumCount(int[] A, int[] B, int[] C, int[] D) { Map map = new HashMap(); for (int i = 0; i < A.length; i++) { for (int j = 0; j < B.l
2017-01-01 21:39:29 286
原创 LeetCode 449. Serialize and Deserialize BST
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Codec {
2017-01-01 21:17:20 514
原创 LeetCode 12. Integer to Roman
public class Solution { public String intToRoman(int num) { StringBuilder sb = new StringBuilder(); char[] ones = {'I', 'X', 'C', 'M'}; char[] fives = {'V', 'L', 'D'};
2017-01-01 20:09:46 313
原创 LeetCode 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 {
2017-01-01 14:42:59 188
原创 LeetCode 477. Total Hamming Distance
public class Solution { public int totalHammingDistance(int[] nums) { int total = 0; int l = nums.length; for (int i = 0; i < 32; i++) { int count = 0; fo
2017-01-01 14:37:55 196
Deep Learning中文版
2017-05-02
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人