Question bank › Sliding Window
Dsa Sliding Window Medium

Words Found in Dictionary

Given a sentence formed by a string `text` and a list of words `dictionary`, determine if all the words in the dictionary can be found within any contiguous substring of `text` of given length `k`. Input: - The first line contains an integer k (1 ≤ k ≤ 1000), the length of the substring. - The second line contains the text string, which can be up to 10000 characters. - The third line contains an integer m (1 ≤ m ≤ 100), the number of words in the dictionary. - The fourth line contains the words of the dictionary, separated by spaces. Output: - Print 'True' if all words can be found in any contiguous substring of length `k`; otherwise print 'False'. Example: Input: 10 hellothere 3 hello there hi Output: True

Key concepts

sliding_windowstringshashmap

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.