Feature #6: Combine Similar Messages

Implementing the "Combine Similar Messages" feature for our "Facebook" project.

Description

Someone is posting messages on Facebook that are apparently gibberish. Research has indicated that the author picks every word and mutates it by adding a fixed offset value to each letter in the word. For example, they may mutate hy to iz by adding 1 to each letter of hy. Similarly, they may mutate hy to ja by adding 2 to each letter of hy, etc. We want to decode these messages. The first step is to group all the words that may be mutations of each order to make further analysis easier.

We’ll be provided with an array of strings in which each string represents a garbled message. Our task is to group all the messages that differ by the same number of offsets in each of their characters.

Here is an illustration of this process:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.