首页 > 解决方案 > 使用不同日期的购买清单为客户查找最有可能的购买

问题描述

我很难找到解决这个问题的有效方法。假设您在不同的日子用不同的品牌购买了这些商品。

String []  day1= {"Nike", "Adidas", "Croc"};
String []  day2= {"Adidas", "Croc", "Reebok"};
String []  day3= {"Croc", "Reebok", "Sketchers"};

然后,您必须为每个品牌打印最有可能购买的商品。

For example:
Nike -> Adidas, Croc //Adidas and Croc appears most times with Nike
Adidas -> Croc //Croc appears most times with Adidas
Croc -> Adidas //Adidas appears most times with Croc

我已经考虑了几个选项。就像使用地图来存储品牌之间的映射一样。但这需要遍历地图,我认为有一个更有效的算法。

谢谢

标签: algorithmsorting

解决方案


推荐阅读