Description
FJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a certain order and then sum adjacent numbers to produce a new list with one fewer...
分类:
其他好文 时间:
2014-08-20 10:33:36
阅读次数:
256
今晚再刷一题,题目如下:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices o...
分类:
其他好文 时间:
2014-08-20 01:20:15
阅读次数:
197
Description
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example, the name "anna" is a palindrome. Numbers can also be palindromes (e.g.
151 or 753357)....
分类:
其他好文 时间:
2014-08-19 12:57:34
阅读次数:
189
Given a collection of numbers, return all possible subclasses. 1 public class Solution { 2 public List> permute(int[] num) { 3 ArrayList...
分类:
其他好文 时间:
2014-08-19 09:22:03
阅读次数:
198
Selection:selection is a trivial problem if the input numbers are sorted. If we use a sorting algorithm having O(nlgn) worst case running time, then t...
分类:
其他好文 时间:
2014-08-19 04:50:43
阅读次数:
200
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possibl...
分类:
其他好文 时间:
2014-08-19 00:57:53
阅读次数:
213
The binomial coefficient C(m,n) is defined as
m!
C(m,n) = --------
n!(m-n)!
Given four natural numbers p, q, r, and s, compute the the result of dividing
C(p,q) by C(r,s).
T...
分类:
其他好文 时间:
2014-08-18 23:37:43
阅读次数:
274
先是想筛法素数表啊,然后1~2000000000枚举打表啊,结果越想越不对。
后来想到唯一分解定理,可是怎么实现呢。。果然还是需要努力啊。。
研究了discuss代码,码之~
~~~~
dp的思想,若dp[i]是Humble Numbers,那么dp[i]*2,dp[i]*3,dp[i]*5,dp[i]*7都将是Humble Numbers。
所以只需要注意连续性便好了。
#inclu...
分类:
其他好文 时间:
2014-08-18 18:32:52
阅读次数:
166
A pair of numbers has a unique LCM but a single number can be the
LCM of more than one possible pairs. Forexample 12 is the
LCM of (1, 12), (2, 12),
(3,4) etc. For a given positive integer N, the ...
分类:
其他好文 时间:
2014-08-18 16:25:24
阅读次数:
240
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T....
分类:
其他好文 时间:
2014-08-17 17:03:22
阅读次数:
184