DEV Community

Discussion on: A common coding interview question

Collapse
 
philipgpm profile image
Philip Georgiev

coderbyte.com/results/philipgg:Fin...

I submitted a 0(2n-a) where a is the number of repetitive elements.

The idea is to use that the arrays are sorted so always increment from where we are.

if the elements are matching, save and then increment both counters.

Else increment the count of the array which has the lower number, to try to find the bigger one. (this is auto-switching between the two.)

Collapse
 
elisabethgross profile image
elisabethgross

Nice! Was waiting for someone to come up with this one!

Collapse
 
ferceg profile image
ferceg

My solution was the same.
When it comes to challenges I prefer algorithms that can be written in pseudocode and don't use many special (or language-specific) data types.