- 博客(41)
- 收藏
- 关注
原创 Leetcode no. 78
78. Subsets Given a set of distinct integers, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplic
2016-04-28 17:20:18 329
转载 Leetcode no. 139
139. Word BreakGiven a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, given
2016-04-26 16:28:42 262
原创 Leetcode no. 18
18. 4SumGiven an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of targe
2016-04-26 14:45:43 286
原创 Leetcode no. 16
16. 3Sum Closest Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that
2016-04-26 11:38:55 282
原创 Leetcode no. 21
21. Merge Two Sorted Lists Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists./** * Def
2016-04-26 10:38:49 244
原创 Leetcode no. 15
15. 3SumGiven an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elem
2016-04-25 09:38:56 261
原创 Leetcode no. 104
104. Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node
2016-04-24 21:02:43 278
原创 Leetcode no. 312
312. Burst BalloonsGiven n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst b
2016-04-24 19:27:53 327
原创 Leetcode no. 70
70. Climbing StairsYou are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the t
2016-04-24 19:26:41 237
原创 Leetcode no. 337
337. House Robber III The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and o
2016-04-24 19:25:23 280
原创 Leetcode no. 213
213. House Robber IINote: This is an extension of House Robber.After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will n
2016-04-24 19:23:14 238
原创 Leetcode no. 198
198. House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them
2016-04-23 16:55:05 269
原创 Leetcode no. 226
226. Invert Binary Tree Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by
2016-04-23 16:53:25 230
原创 Leetcode no. 214
214. Shortest PalindromeGiven a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing th
2016-04-23 16:51:29 304
原创 Leetcode no. 5
5. Longest Palindromic SubstringGiven a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palind
2016-04-23 16:49:48 242
原创 Leetcode no. 69
69. Sqrt(x)Implement int sqrt(int x).Compute and return the square root of x.public class Solution { public int mySqrt(int x) { if (x<=0) return 0; if (x>
2016-04-18 23:38:11 277
原创 Leetcode no. 169
169. Majority Element Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-em
2016-04-17 00:38:28 230
转载 Java 序列化和反序列化
一、序列化和反序列化的概念 把对象转换为字节序列的过程称为对象的序列化。 把字节序列恢复为对象的过程称为对象的反序列化。 对象的序列化主要有两种用途: 1) 把对象的字节序列永久地保存到硬盘上,通常存放在一个文件中; 2) 在网络上传送对象的字节序列。 在很多应用中,需要对某些对象进行序列化,让它们离开内存空间,入住物理硬盘,以便长期保存。比如最常见的是
2016-04-15 17:00:33 216
原创 Leetcode no. 52
52. N-Queens IIFollow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.public class Solution { int count=0;
2016-04-14 16:48:10 250
原创 Leetcode no. 51
51. N-QueensThe n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the
2016-04-14 15:48:29 230
原创 Leetcode no. 81
81. Search in Rotated Sorted Array IIFollow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a functi
2016-04-13 21:50:39 206
原创 Leetcode no.33
33. Search in Rotated Sorted ArraySuppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target valu
2016-04-13 20:01:35 204
原创 Leetcode no. 39
39. Combination SumGiven a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be cho
2016-04-12 21:37:30 268
原创 Leetcode no. 330
330. Patching ArrayGiven a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum of some
2016-04-12 16:37:45 282
原创 Leetcode no. 141
141. Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?/** * Definition for singly-linked list. * class Lis
2016-04-12 12:14:56 232
原创 Leetcode no. 182
182. Duplicate EmailsWrite a SQL query to find all duplicate emails in a table named Person.+----+---------+| Id | Email |+----+---------+| 1 | a@b.com || 2 | c@d.com || 3 | a@b.com
2016-04-12 10:34:19 417
原创 Leetcode no. 84
84. Largest Rectangle in HistogramGiven n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.
2016-04-12 00:10:09 221
原创 Leetcode no. 164
164. Maximum GapGiven an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 if the array contain
2016-04-11 17:16:07 296
转载 Leetcode no. 201
201. Bitwise AND of Numbers RangeGiven a range [m, n] where 0 For example, given the range [5, 7], you should return 4.public class Solution { public int rangeBitwiseAnd(int m, int n
2016-04-10 16:58:40 250
原创 Leetcode no. 313
313. Super Ugly NumberWrite a program to find the nth super ugly number.Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k. For ex
2016-04-09 22:49:44 296
原创 Leetcode no. 228
228. Summary RangesGiven a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"].public class Solution {
2016-04-09 15:17:44 291
原创 Leetcode no. 80
80. Remove Duplicates from Sorted Array IIFollow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your func
2016-04-08 10:48:22 476
原创 Leetcode no. 26
26. Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for
2016-04-07 21:29:46 236
转载 Leetcode no. 238
238. Product of Array Except SelfGiven an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]
2016-04-07 18:04:32 251
原创 Leetcode no. 40
40. Combination Sum IIGiven a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only
2016-04-07 17:13:08 241
原创 Leetcode no. 181 (sql)
181. Employees Earning More Than Their Managers# Write your MySQL query statement belowselect E.namefrom Employee E, Employee Hwhere E.ManagerId= H.Id and E.Salary> H.SalaryThe Employee tab
2016-04-06 14:45:36 718 1
原创 Leetcode no. 283
283. Move ZeroesGiven an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3,
2016-04-06 13:52:55 353
原创 Leetcode no. 335
335. Self CrossingYou are given an array x of n positive numbers. You start at point (0,0) and moves x[0] metres to the north, then x[1] metres to the west, x[2] metres to the south,x[3] met
2016-04-05 20:23:21 258
原创 Leetcode no. 279
279. Perfect SquaresGiven a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 1
2016-04-05 18:24:10 342
原创 Leetcode no. 37
37. Sudoku SolverWrite a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solu
2016-04-03 00:16:50 266
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人