Feature #5: Flag Words

Description

Facebook recently conducted a survey on the techniques people use to hide offensive or profane words. The goal was to flag such words in the posts and messages of users. The most observable pattern was that the characters of a word were repeated multiple times to avoid detection. A single character in a word was observed to be repeated at least 3 times. This means that characters repeated less than 3 times will be ignored in the detection process.

We’ll be provided with a string, S, representing the profane or offensive input word and another string, W, representing the original word. We have to determine if the original word, W, can be modified into S following the above-mentioned rules.

Solution

Since we have to observe letters of two strings at a time, we can follow a two-pointer approach to solve this problem.

Here is how we will implement this feature:

  1. Initialize two ...

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy