Challenging question find if there is an element repeating himself n/k times
- by gleb-pendler
here how it's goes:
You have an array size n and a constant k (whatever)
you can assume the the array of int type tho it kind be of whatever type but just for the clearane let assume it's an integer.
Describe an algorithm that finds if there is an element/s that repeat itself at least n/k times... if there is return one - do it in linear time running O(n)
Imortent:
now the catch do this algorithm or even pseuo-code using a constant usage of memory and running over the array only TWICE!!!