Google | Phone | Generate Substrings and Append Characters

Anonymous User
3477
Mar 30, 2024
Mar 30, 2024

Given a string, your task is to generate a list of substrings such that while appending all of the substrings in the list should give back the original string. If the resulting substring is not already present in the list, it should be added to the list.

Examples:

Input: "GOOOOOOGLE"
Output: ["G", "O", "OO", "OOO", "GL", "E"]

Input: "GOOOOOOGLEG"
Output: ["G", "O", "OO", "OOO", "GL", "E", "G"]
handling edge case

Comments (19)