You are viewing a single comment's thread. Return to all comments →
Wouldn't it be faster to maintain your count in the initial iteration?
static int birthdayCakeCandles(int[] ar) { int height = ar[0]; int count = 1; for (int i = 1; i < ar.Count();i++) { if (ar[i] > height){ height = ar[i]; count = 1; } else if (ar[i] == height){ 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 →
Wouldn't it be faster to maintain your count in the initial iteration?