Skip to content

Practice Delete Characters to Make Fancy String

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1957
LeetCode Problem

Delete Characters to Make Fancy String

Problem Statement

A fancy string is a string where no three consecutive characters are equal. Given a string s, delete the minimum possible number of characters from s to make it fancy. Return the final string after the deletion. It can be shown that the answer will always be unique.

Source: Delete Characters to Make Fancy String on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "leeetcode"
Output
"leetcode"

# Example 2

Input
s = "aaabaaaa"
Output
"aabaa"

# Example 3

Input
s = "aab"
Output
"aab"

Constraints

1 <= s.length <= 10^5
s consists only of lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Delete Characters to Make Fancy String.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.