Hi everyone,
Wanted to check if someone could suggest a solution to following problem:
Given a string of words if a target (for example "breath") is present such that each letter appears in a different word,return true or false,
The order of words have to be maintained.
Example:
input:"abc prq def at pqr the hello" target: breath
a[b]c
p[r]q
d[e]f
[a]t pqr
[t]he
[h]ello
output:true
Follow up: what if words can be upto k distance apart? that is <=k
k characters apart from the currently matched character !!
Thank you in advance.