Given an array, iterate through it: if the current element equals the next, double the current and set the next to 0. After processing, shift all zeros to the end of the array.
You've read your 3 free write-ups
Sign up free to keep reading. Your account opens the first 10 questions of every company.