Skip to main content

Remove Extra Duplicate Letters

MIDDLE

Remove Extra Duplicate Letters

Remove consecutive duplicate letters from a string, keeping only one occurrence.

Requirements:

  • Remove consecutive duplicates
  • Keep only one of each consecutive character
  • Maintain original order

Example:

Input: "aabbccdd"
Output: "abcd"

Input: "bookkeeper"
Output: "bokeper"

Examples:

Input 1:{"s":"aabbccdd"}
Output 1:"abcd"
Input 2:{"s":"bookkeeper"}
Output 2:"bokeper"

Loading editor...

Run your code to see results

Click the Run button above