人人车笔试
人人车的笔试题,有不懂的留言,我修改
第一题:人民币分为(1,5,10,20,50,100)的金额,若交易金额为19,收银(50),找零(20+10+1)交易所需人民币张数为4.或者收银(10+5+1+1+1+1)交易所需人民币张数为6.输入交易金额n,输出交易所需最少人民币数量
第二题:输入一个数,判断其是否为快乐的数(各位数的平方和最后得1),陷入死循环则不是快乐的数
例如:输入:19
1^2+9^2=82;(9^2是9的平方)
8^2+2^2=68;
6^2+8^2=100;
1^2+0^2+0^2=1;
则19为快乐的数
例如:输入:19
1^2+9^2=82;(9^2是9的平方)
8^2+2^2=68;
6^2+8^2=100;
1^2+0^2+0^2=1;
则19为快乐的数
第三题:求字符串数组的前缀公共子串
{“abcdef",
"abcsfds",
"abctyu"}
则结果为“abc”
{“abcdef",
"dbcsfds",
"sbctyu"}
则结果为“”(为空)
{“abcdef",
"abcsfds",
"abctyu"}
则结果为“abc”
{“abcdef",
"dbcsfds",
"sbctyu"}
则结果为“”(为空)