LEETCODE
文章平均质量分 84
只只只只只只
这个作者很懒,什么都没留下…
展开
-
【leetcode】423. Reconstruct Original Digits from English
这题我们只要统计关键的字符就能够统计出每个单词出现的次数,有写单词需要统计前驱字符才能计算出来首先:具有独特字符的zero/two/six/eightseven(six)/five(seven)four(five)/nine(eight/six/five)/one(zero/two/four)/three(zero/four)public class Solution {原创 2016-11-28 21:21:06 · 191 阅读 · 0 评论 -
【Leetcode】448. Find All Numbers Disappeared in an Array
448. Find All Numbers Disappeared in an ArrayGiven an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1,原创 2017-01-16 17:21:25 · 264 阅读 · 0 评论 -
【Leetcode】468. Validate IP Address
468. Validate IP AddressWrite a function to check whether an input string is a valid IPv4 address or IPv6 address or neither.IPv4 addresses are canonically represented in dot-decimal notatio原创 2017-01-17 17:51:57 · 255 阅读 · 0 评论 -
【Leetcode】216. Combination Sum III
216. Combination Sum IIIFind all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of nu原创 2017-02-27 22:26:41 · 202 阅读 · 0 评论 -
【Leetcode】106. Construct Binary Tree from Inorder and Postorder Traversal
106. Construct Binary Tree from Inorder and Postorder TraversalGiven inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist原创 2017-03-01 22:43:20 · 212 阅读 · 0 评论 -
【Leetcode】449. Serialize and Deserialize BST
449. Serialize and Deserialize BSTSerialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitte原创 2017-02-23 00:03:05 · 333 阅读 · 0 评论 -
【Leetcode】227. Basic Calculator II
227. Basic Calculator IIImplement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *, / operators and empty spaces原创 2017-02-23 19:56:02 · 244 阅读 · 0 评论 -
【Leetcode】495. Teemo Attacking
In LLP world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking ascending time series towards Ashe and the poisoning tim原创 2017-02-23 22:02:01 · 246 阅读 · 0 评论 -
【Leetcode】442. Find All Duplicates in an Array
442. Find All Duplicates in an ArrayGiven an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in原创 2017-02-25 12:03:45 · 243 阅读 · 0 评论 -
【Leetcode】380. Insert Delete GetRandom O(1)
380. Insert Delete GetRandom O(1)Design a data structure that supports all following operations in average O(1) time.insert(val): Inserts an item val to the set if not already present.re原创 2017-02-25 16:00:21 · 289 阅读 · 0 评论 -
【Leetcode】53. Maximum Subarray
53. Maximum SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contigu原创 2017-02-25 17:27:01 · 204 阅读 · 0 评论 -
【Leetcode】463. Island Perimeter
463. Island PerimeterYou are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonall原创 2017-01-16 11:26:35 · 216 阅读 · 0 评论 -
【Leetcode】475. Heaters
475. HeatersWinter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the houses.Now, you are given positions of houses and heater原创 2017-01-16 10:21:11 · 513 阅读 · 0 评论 -
【Leetcode】22. Generate Parentheses
先贴代码:public class Solution { List aList = new ArrayList(); public List generateParenthesis(int n) { if(n == 0){ return aList; } travel("",n,n);原创 2016-11-28 21:59:14 · 269 阅读 · 0 评论 -
【Leetcode】318. Maximum Product of Word Lengths
方法一:(空间复杂度O(1),时间复杂度O(n^2))很简单的多次遍历的方式:public int maxProduct(String[] words) { int res = 0; boolean flag; for(int i=0;i for(int j=i+1;j if原创 2016-11-28 22:45:36 · 264 阅读 · 0 评论 -
【Leetcode】77. Combinations
先贴代码:转载自:http://blog.csdn.net/happyaaaaaaaaaaa/article/details/51564160public class Solution { public List> combine(int n, int k) { List> resList = new ArrayList>(); List te转载 2016-11-30 22:21:45 · 264 阅读 · 0 评论 -
【Leetcode】78. Subsets
先上代码:public class Solution { public List> subsets(int[] nums) { List> res = new ArrayList>(); List temp = new ArrayList(); dfs(res,temp,nums,0); return res;原创 2016-11-30 22:37:45 · 140 阅读 · 0 评论 -
【Leetcode】153. Find Minimum in Rotated Sorted Array
题目分析:Suppose 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).Find the minimum element.You may assume no duplicate原创 2016-12-01 22:22:32 · 159 阅读 · 0 评论 -
【Leetcode】398. Random Pick Index
问题分析:Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array.Note:The a原创 2016-12-01 23:16:44 · 332 阅读 · 0 评论 -
【Leetcode】48. Rotate Image
题目分析:You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?Subscribe to see which companies ask原创 2016-12-02 11:47:53 · 231 阅读 · 0 评论 -
【Leetcode】476. Number Complement
题目:476. Number ComplementGiven a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note:The given integer is原创 2017-01-14 12:05:18 · 386 阅读 · 0 评论 -
【Leetcode】445. Add Two Numbers II
445. Add Two Numbers IIYou are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add原创 2017-01-14 13:00:12 · 261 阅读 · 0 评论 -
【Leetcode】482. License Key Formatting
482. License Key FormattingNow you are given a string S, which represents a software license key which we would like to format. The string S is composed of alphanumerical characters and dashes.原创 2017-01-15 14:48:03 · 201 阅读 · 0 评论 -
【Leetcode】287. Find the Duplicate Number
287. Find the Duplicate NumberGiven an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that th原创 2017-02-26 11:27:13 · 346 阅读 · 0 评论