We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
publicstaticList<Integer>acmTeam(List<String>topic){HashMap<Integer,Integer>teamTopicMap=newHashMap<>();//create a map of occurances of amount of topicsfor(inti=0;i<topic.size();i++){for(intj=i;j<topic.size();j++){inttopicCounter=topicPointsCounter(topic.get(i),topic.get(j));if(teamTopicMap.containsKey(topicCounter)){teamTopicMap.put(topicCounter,teamTopicMap.get(topicCounter)+1);}else{teamTopicMap.put(topicCounter,1);}}}intmax=0;for(inttopicNumber:teamTopicMap.keySet()){if(topicNumber>=max)max=topicNumber;}returnArrays.asList(max,teamTopicMap.get(max));}publicstaticinttopicPointsCounter(Stringinput1,Stringinput2){intcounter=0;for(inti=0;i<input1.length();i++){if(input1.charAt(i)=='1'||input2.charAt(i)=='1')counter++;}returncounter;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
ACM ICPC Team
You are viewing a single comment's thread. Return to all comments →
Java Easy to understand solution: