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.
funpickingNumbers(a:Array<Int>):Int{// Write your code herevarmaxLength=1varmaxValue=0valfrequencies=MutableList(100){0}a.forEach{num->maxValue=Math.max(num,maxValue)frequencies[num]++}for(iin1..maxValue){valsubListLength=frequencies[i]+frequencies[i-1]maxLength=Math.max(maxLength,subListLength)}returnmaxLength}``
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Picking Numbers
You are viewing a single comment's thread. Return to all comments →
Flag array method (write in kotlin):