You are viewing a single comment's thread. Return to all comments →
first sort then try
Arrays.sort(ar); int count = 0; int n=ar.length; int max=ar[n-1]; for(int i = ar.length-1; i >= 0; i--) { if (ar[i] == max) { count++; } else { return count; } } return count;
Seems like cookies are disabled on this browser, please enable them to open this website
Birthday Cake Candles
You are viewing a single comment's thread. Return to all comments →
first sort then try
Arrays.sort(ar); int count = 0; int n=ar.length; int max=ar[n-1]; for(int i = ar.length-1; i >= 0; i--) { if (ar[i] == max) { count++; } else { return count; } } return count;