I'm trying to solve this by diving into two parts. First to get the lexicographically smallest values between a list of strings and then to check if it is not a substring in the given strings.
For the substring check part,
Create a Set from the given list of strings to remove duplicates
Set a boolean flag to true
- Loop through the Set and use String contains to check if the new_string
- If found, make flag as false and break
- After the end of the loop check if the flag is true
- If the flag is true, use this solution else go for the next value of new_string.
How do I find the list of lexicographically smallest values? I checked this to understand what lexicographically smallest means. In my case since there is a list of values should I first find the lexicographically smallest of each string and then try to find the new string which is smaller than these?
I don't need the code for it. I just want a pointer in the right direction and how should I approach this?
Note: I'm using Java