Source Code:thecodingsimpl...
Solution:
- We calculate word length & total words, create a frequency map of given words
- Now we iterate each index & check if word exists in frequency map
- If doesn't exists then break.
- We also take seenWords map, where we put words which are seen in for this index
- If seenWords value is more than actual frequency exists, then also we break
- If totalWords are equal to the found words, then we add the index in result.
- At last, we return result
Time Complexity: O(n * m * length), where n is number of values in array, m is total words & length is each word length
Space Complexity: O(m)
For more info, please see the video.
CHECK OUT CODING SIMPLIFIED
/ codingsimplified
★☆★ VIEW THE BLOG POST: ★☆★
thecodingsimpli...
I started my KZitem channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 500+ videos.
★☆★ SUBSCRIBE TO ME ON KZitem: ★☆★
www.youtube.co...
★☆★ Send us mail at: ★☆★
Email: thecodingsimplified@gmail.com
Негізгі бет String - 16: Find Substrings formed using Concatenation of all given words
Пікірлер: 33