In this post, we will solve Find a Sub-Word HackerRank Solution. This problem (Find a Sub-Word) is a part of HackerRank Regex series.
Find a Sub-Word – HackerRank Solution
Python
import re if __name__ == '__main__': n = int(input()) nline = '\n'.join(input() for _ in range(n)) q = int(input()) for _ in range(q): s = input() print(len(re.findall(r'\B(%s)\B' % s, nline)))
Note: This problem (Find a Sub-Word) is generated by HackerRank but the solution is provided by CodingBroz. This tutorial is only for Educational and Learning purpose.