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.
// Write your code hereintmaxcount=0;for(inti=0;i<a.size();i++){intv=a.get(i);intcount=1;for(intj=0;j<a.size();j++){if(i==j){continue;}intq=a.get(j);if(v==q||v==q-1){count++;}}if(count>maxcount){maxcount=count;}returnmaxcount;}
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 →
Simple unsorted n-squared solution.