- 博客(9)
- 收藏
- 关注
原创 Leetcode--648. Replace Words
题目In English, we have a concept called root, which can be followed by some other words to form another longer word - let’s call this word successor. For example, the root an, followed by other, which c
2017-07-25 10:54:11 974
原创 Leetcode--60. Permutation Sequence
题目The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3):“123” “132” “213” “231” “31
2017-07-03 11:14:12 310
原创 Leetcode--Add to List 215. Kth Largest Element in an Array
题目Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example, Given [3,2,1,5,6,4] and k = 2, return 5. 寻找
2017-07-03 11:05:23 344
原创 Leetcode--139. Word Break
题目Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You may ass
2017-07-03 10:54:57 332
原创 Leetcode--Add to List 201. Bitwise AND of Numbers Range
题目Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.For example, given the range [5, 7], you should return 4. 数字范围位相与思路直接平移m和n,每次向右移一
2017-07-01 15:34:22 303
原创 Leetcode--191. Number of 1 Bits
题目Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11’ has binary representation 00000000000
2017-07-01 13:18:16 364
原创 40亿个非负整数中找到没出现的数
题目原问题:32位无符号整数的范围是0-4294967295,现在有一个正好包含40亿个无符号整数的文件,所以在整个范围中必然有没出现过的数。最多一可使用1GB的内存空间,怎么找到左右没出现过的数?进阶:内存限制为10MB,但是只用找到一个没有出现过的数即可。思路1、原问题如果用哈希表来保存出现过的数,那么如果40亿个数都不同,则哈希表记录为40亿条,每条记录占4B,共占用内存40亿*4B=1
2017-07-01 11:33:27 729
原创 只用2GB内存在20亿个整数中找到出现次数最多的数
题目有一个包含20亿个全是32位整数的大文件,在其中找到出现次数最多的数,内存限制为2GB。思路在整数中找到出现次数最多的数,通常做法是使用哈希表对出现的每一个数做词频统计,Key为整数,Value为出现的次数。本题中,32位的整数作为Key,需要4B空间,Value最大值为20亿(在20个数均为同一个数的情况下),用32位的整数完全可以存储,也需要用4B内存空间,这样,一个键值对需要占用8B的内存
2017-07-01 10:50:15 906
原创 Leetcode--189. Rotate Array
题目Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note: Try to come up as many solutions as you can, th
2017-07-01 10:28:02 300
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人