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.
Create Pair counter which will count the number of paired element
If pair matches then increase counter by 1,
publicstaticintsockMerchant(intn,List<Integer>ar){// Write your code hereint[]arr=ar.stream().mapToInt(x->x).sorted().toArray();intpairCounter=0;for(inti=0;i<arr.length-1;i++){if(arr[i]==arr[i+1]){i=i+1;pairCounter++;}}returnpairCounter;}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sales by Match
You are viewing a single comment's thread. Return to all comments →