- 博客(12)
- 收藏
- 关注
原创 leetcode 204:Count Primes
原题:Count the number of prime numbers less than a non-negative number, n.求小于正整数n的质数的个数通常我们的做法是从最小的质数2开始遍历直到n,判断其中每一个数是否为质数,当n很大的时候,肯定超时。有更高效的解法如下:质数只能被1和他自己整除,也就是说他不包含基本因子2,3,5,7等我们可以排除上述这些数来大大提高遍历效率2是最
2016-07-15 16:10:33 450
原创 leetcode:First Missing Positive
原题:Given an unsorted integer array, find the first missing positive integer.For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant space
2016-07-14 22:06:54 226
原创 leetcode:Binary Tree Level Order Traversal
原题: Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level). For example: Given binary tree [3,9,20,null,null,15,7] 3
2016-07-13 23:19:24 332
原创 leetcode 125:Valid Palindrome
原题: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example, “A man, a plan, a canal: Panama” is a palindrome. “race a car” i
2016-07-12 09:36:47 361
原创 leetcode:Counting Bits
原题: Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.Example: For num = 5 y
2016-07-11 19:48:33 356
原创 leetcode:Top K Frequent Elements
原题: Given a non-empty array of integers, return the k most frequent elements. For example, Given [1,1,1,2,2,3] and k = 2, return [1,2].Note:You may assume k is always valid, 1 ≤ k ≤ number of unique
2016-07-10 15:15:45 401
原创 leetcode:Isomorphic Strings
原题: Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with another
2016-07-09 20:02:27 364
原创 leetcode: Word Pattern
原题: Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.Exampl
2016-07-09 19:03:26 404
原创 leetcode :Reverse Vowels of a String
原题:Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Given s = "hello", return "holle".Example 2:Given s = "leetcode", return "leotcede".
2016-07-09 14:04:01 404
原创 leetcode: Missing 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 implement it without usin
2016-07-09 13:31:42 393
原创 leetcode:Water and Jug Problem
原题:You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available.You need to determine whether it is possible to measure exactly z litres using the
2016-07-08 22:20:15 634
原创 leetcode:Minimum Window Substring题解(Java)
原题:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BA
2016-07-08 20:49:50 362
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人