Smallest KMP
Chef has a string $S$. He also has another string $P$, called *pattern*. He wants to find the pattern in $S$, but that might be impossible. Therefore, he is willing to reorder the characters of $S$ in such a way that $P$ occurs in the resulting string (an anagram of $S$) as a substring. Since this problem was too hard for Chef, he decided to ask you, his genius friend, for help. Can you find th
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start