+ 1

Define a function named longest_duplicates that returns the length of the longest sub-array of duplicates in a given sort array.

Need urgent help!!

3rd Mar 2017, 5:52 AM
Tosrif Jahan Sakib
Tosrif Jahan Sakib - avatar
2 Respuestas
+ 2
send the sorted array in as a parameter. 2 variables. one for the longest count. one for the current count both start at 0 start at index 0 and walk until size-1, for last index make current increase as long as index x+1 is the same as x. if the current count ever exceeds the longest count, After the indexes are different numbers, re assign the length. you could also keep a variable for number or first index of the longest. as a reference. hope this helps!!
3rd Mar 2017, 8:30 AM
Michael Szczepanski
Michael Szczepanski - avatar
0
Thank you very much.
6th Mar 2017, 3:43 PM
Tosrif Jahan Sakib
Tosrif Jahan Sakib - avatar