Hack Frontend Community

Remove Extra Letter Duplication

Tinkoff
Write a function that takes a string containing extra letter duplication (e.g., 'neeeeed'), and returns a string where each letter appears only once consecutively.
  • - Letter case is preserved.
  • - Non-letter characters also remain in the string, but without duplication.

Examples:

Input 1: "нууужно"
Output 1: "нужно"
Input 2: "ллллиииишшшнийййй тттексттт"
Output 2: "лишний текст"
Run your code to see results.