Tuesday, May 5, 2015

Addictive Number

Q:
Problem (Epic): Additive numbers are defined to be a positive integer whose digits form an additive sequence. E.g. 11235 (1+1=2, 1+2=3, 2+3=5). What makes it difficult is that 12,122,436 is also one (12+12=24, 12+24=36). Given a range of integers, find all the additive numbers in that range..


A:
自己的思路是先确定是几位的数字,例如从 1 到99999,我们就分别设置数组长为1 到5.

然后对那么长的数组,分别求addative number. 再检查是否within range 



XXX number  -------- sorry (I forget the name ):
find all XXX number within range [low high]
XXX number is defined as :
  each adjacent position will differ only 1.   for example 8798 is a XXX number,  890 is NOT.

permutaion II

Given a string, print all its permutations, (only lower case character can be permuted)


Contagious patient
就是一个party,互相握手。 有一个人开始有传染病。 最终多少人会有传染病?
输入是一个数值, 和一个2D array.

No comments:

Post a Comment