Domanda di colloquio di Microsoft

Given an char array. write a function that 'collapse' the array and send it back. e.g: for a given array 'abccdeefaassf' return abcdefasf' this can be done in O(n).