上一页 1 2 3 4 5 6 ··· 18 下一页
摘要: 题目描述: Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if th 阅读全文
posted @ 2016-08-17 00:19 scottwang 阅读(591) 评论(0) 推荐(0) 编辑
摘要: 问题:如何随机从n个对象中选择一个对象,这n个对象是按序排列的,但是在此之前你是不知道n的值的。 思路:如果我们能够知道n的值,那么问题就简单了,只需要randInt(n)得到确切的位置,然后选择出该位置的值即可,实现概率为1/n的抽样。 但现在我们并不知道n的值,这个问题便抽象为蓄水池抽样,即从一 阅读全文
posted @ 2016-08-11 00:08 scottwang 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Example:Given n = 2, return 91. (The answer should b 阅读全文
posted @ 2016-08-03 00:03 scottwang 阅读(244) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 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 阅读全文
posted @ 2016-07-31 16:55 scottwang 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 题目描述: We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you gues 阅读全文
posted @ 2016-07-30 22:33 scottwang 阅读(454) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example:Given num = 16, return true. Given num = 5, ret 阅读全文
posted @ 2016-07-30 20:58 scottwang 阅读(382) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 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:Gi 阅读全文
posted @ 2016-07-28 23:35 scottwang 阅读(316) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Given a linked list, determine if it has a cycle in it. 解题思路: 快的指针和慢的指针 代码如下: 阅读全文
posted @ 2016-07-28 00:47 scottwang 阅读(277) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one trans 阅读全文
posted @ 2016-07-27 22:57 scottwang 阅读(835) 评论(2) 推荐(0) 编辑
摘要: 题目描述: Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each 阅读全文
posted @ 2016-07-27 00:32 scottwang 阅读(238) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 18 下一页