PayU interview question

Replace adjacent duplicate characters appearing in a String array by single character