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.
funknownTopics(topic1:String,topic2:String):Int{varres=0for(tin0..topic1.length-1){if(topic1.get(t)=='1'||topic2.get(t)=='1')res++}returnres}/* * Complete the 'acmTeam' function below. * * The function is expected to return an INTEGER_ARRAY. * The function accepts STRING_ARRAY topic as parameter. */funacmTeam(topics:Array<String>):Array<Int>{// Write your code herevarscores=mutableListOf<Int>()for(iin0..topics.size-2){varp1=topics.get(i)for(jini+1..topics.size-1){varp2=topics.get(j)scores.add(knownTopics(p1,p2))}}scores.sortDescending()varres=Array<Int>(2){0;0}res[0]=scores.get(0)res[1]=scores.count{it==res[0]}returnres}
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 →
my kotlin solution