In this post, we will solve Find a Word HackerRank Solution. This problem (Find a Word) is a part of HackerRank Regex series.
Solution – Find a Word – HackerRank Solution
import re n = int(input()) sen = list() for i in range(n): x = str(input()) sen.append(x) t = int(input()) for i in range(t): x = str(input()) p = re.compile('(?:\W|\A)'+x+'(?=\W|\Z)') c = 0 for y in sen: c += len(re.findall(p, y)) print(c)
Note: This problem (Find a Word) is generated by HackerRank but the solution is provided by CodingBroz. This tutorial is only for Educational and Learning purpose.