I am currently passing 4 of the 5 hidden test cases for this challenge and would like some input
Quick problem description:
You are given two input strings, String chunk and String word
The string "word" has been inserted into "chunk" some number of times
The task is to find the shortest string possible when all instances of "word" have been removed from "chunk".
Keep in mind during removal, more instances of the "word" might be created in "chunk". "word" can also be inserted anywhere, including between "word" instances
If there are more the one shortest possible strings after removal, return the shortest word that is lexicographic-ally the earliest.
This is easier understood with examples:
Inputs:
(string) chunk = "lololololo"
(string) word = "lol"Output:
(string) "looo" (since "looo" is eariler than "oolo")Inputs:
(string) chunk = "goodgooogoogfogoood"
(string) word = "goo"Output:
(string) "dogfood"
right now I am iterating forwards then backwards, removing all instances of word and then comparing the two results of the two iterations.
Is there a case I am overlooking? Is it possible there is a case where you have to remove from the middle first or something along those lines?
Any insight is appreciated.