- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
亚马逊在线笔试题目
2小时,两个题目。在线编程,英文题目。当时没做好,完了自己把他们完成了。答案是我自己写的,自己测试没问题,若有错误请指正。
Question1/2
Question:
Wehaveanarrayrepresentingcustomer’sshoppingrecords.
Forexample,it’sanarraylikethis:
custA,item1,
custB,item1,
custA,item2,
custB,item3,
custC,item1,
custC,item3,
custD,item2,
ThisarrayindicatesthatcustomerAboughtitem1,customerBboughtitem1,customerAboughtitem2,customerBbought
item3,etc..
ForagivenitemXandshoppingrecordsarray,writecodetofindoutwhatelse(itemY)wasboughtmostlybythecustomers
whoboughtitemX.
Forexample,inaboveexample,ifXisitem1thenYshouldbeitem3.
Rules:
1.Onecustomercanonlybuyoneitemonce.
2.ThemostlybroughtitemshouldnotbeitemX.
3.IfnocustomerbroughtitemX,thenreturn“None”
4.IfallthecustomerswhobroughtitemXonlybroughtitemX,thenreturn“None”
5.ThefirstlineofinputistheitemX.Thesecondlineofinputistheshoppingrecordarray,thisshoppingrecordarrayis
splitbyspace.
6.Iftherearemanyothermostlybroughtitemswhichhaveequallybroughttimes,thenreturnanyoneofthoseitems.
Examples:
Input1:
item1
custAitem1custBitem1custAitem2custBitem3custCitem1custCitem3custDitem2
Output1:
item3
Input2:
item2
custAitem1custBitem1custCitem1custAitem2custBitem3custAitem3
Output2:
item1
(Theoutput2canbeitem3too)
/*Enteryourcodehere.ReadinputfromSTDIN.PrintoutputtoSTDOUT*/
#include
#include
#include
#include
#include
#include
#include
usingnamespacestd;
char*findMostlyBroughtItem(char*shippingRecordArray[],intlength,char*givenItem);
inlineboolisSpace(charx){
returnx==||x==\r||x==\n||x==\f||x==\b||x==\t;
}
char*rightTrim(char*str){
intlen=strlen(str);
while(--len=0){
if(isSpace(str[len])){
str[len]=\0;
}else{
break;
}
}
returnstr;
}
char*getIn
您可能关注的文档
最近下载
- 反渗透计算,输入参数可自动计算.xlsx VIP
- 2025小红书保健行业白皮书.pptx VIP
- 字词梳理及运用-2023学年三年级语文下册期中专项复习(部编版).pdf VIP
- 大班幼儿叙事讲述能力发展的现状调查及培养策略研究.docx VIP
- 第11课 辽宋夏金元的经济、社会与文化(教学课件)——高一历史统编版中外历史纲要上册.pptx VIP
- 中医临床实践指南制定规范ppt课件.ppt VIP
- 泰伯智库-时空智能技术与应用白皮书(2025).pdf
- 高密度沉淀池计算,输入参数可自动计算.xlsx
- 人教版七年级英语下册第五单元测试题-Unit-5-含答案.docx VIP
- 会计职业道德(第2版) 习题答案 王红云 .docx
原创力文档


文档评论(0)