亚马逊在线笔试题目.doc亚马逊在线笔试题目
2小时,两个题目。在线编程,英文题目。当时没做好,完了 自己把他们完成了。答案是我自己写的,自己测试没问题,若有错误 请指正。
Questionl/2
Question:
Wehaveanarrayrepresentingcustomer' sshoppingrecords.
Forexample, it' sanarraylikethis:
cus tA, it eml,
cus tE, it eml,
custA, item2,
custB, item3,
cus tC, it eml,
custC, item3,
custD, item2,
ThisarrayindicatesthatcustomerAboughtiteml, customerBboughti teml, customerAboughtitem2, customerEbought
item3, etc..
ForagivenitemXandshoppingrecordsarray, writecodetof indoutwha telse(itemY)wasboughtmostlybythecustomers
whoboughtitemX.
Forexample, inaboveexample, ifXisitemIthenYshouldbeitem3.
Rules:
.
ThemostlybroughtitemshouldnotbeitemX.
IfnocustomerbroughtitemX, thenreturn "None"
IfallthecustomerswhobroughtitemXonlybroughtitemX, thenretu rn "None"
ThefirstlineofinputistheitemX. Thesecondlineofinputisthesh oppingrecordarray, thisshoppingrecordarrayis
splitbyspace.
Iftherearemanyothermostlybroughtitemswhichhaveequallybrou ghttimes, thenreturnanyoneofthoseitems.
Examples:
Inputl:
iteml custAitemlcustEitemlcustAitem2custEitem3custCitemlcustCitem 3custDitem2
Output1:
it em3
Input2:
it em2
custAitemlcustEitemlcustCitemlcustAitem2custEitem3custAitem
3
Output?:
it eml
(Theoutput2canbeitem3too)
/*Enteryourcodehere. ReadinputfromSTDIN. PrintoutputtoSTDOUT* /
ftinclude
ftinclude
ftinclude
ftinclude
ftinclude
ftinclude
fti
亚马逊在线笔试题目 来自淘豆网m.daumloan.com转载请标明出处.