Substring Concatenation - Java

HARD JAVA

You are given a string, S, and a list of words, L, that are all of the same lengths.
Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without any intervening characters.

Example :
S: "barfoothefoobarman"
L: ["foo", "bar"]

Your output should be [0,9] where order does not matter.

Your Input:
S : "domecodehaha"
L : ["haha","code"]


Submit Answer

NOTE These questions can be solved in either Java , Python , Rust, C++, Go or ! However, the language intended for these questions is mentioned along with the question on the top. You need to submit the solution file for the autograder to grade the submission. If you are submitting in Java, make sure that the class name is Main (with a capital M)


Optional Java Editor for your use