You are viewing a single comment's thread. Return to all comments →
Why not to use first array element like initial value of max ? Does it make any sense ?
static int birthdayCakeCandles(int n, int[] ar) { int max=ar[0]; int num=1; for (int i=1;i<n;i++){ if (ar[i]>max){ max=ar[i]; num=1; } else if (ar[i]==max) num++; } return num; }
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 →
Why not to use first array element like initial value of max ? Does it make any sense ?