#K4096. Anagram Substring
Anagram Substring
Anagram Substring
Given two strings \(S_1\) and \(S_2\), determine whether any anagram of \(S_2\) appears as a substring in \(S_1\). An anagram is a permutation of the characters. For example, if \(S_1 = \texttt{google}\) and \(S_2 = \texttt{ogle}\), then the substring \(\texttt{ogle}\) (which is a permutation of \(S_2\)) appears in \(S_1\), and the answer is 1. Otherwise, the answer is 0.
Note: The formulae are rendered in \(\LaTeX\) format. The input is provided via stdin
and the output should be printed to stdout
.
inputFormat
The input will be given via stdin
as two lines. The first line contains the string \(S_1\) and the second line contains the string \(S_2\). Both strings consist of lowercase English letters.
outputFormat
Output a single integer: 1 if an anagram of \(S_2\) is present as a substring in \(S_1\), otherwise 0. The output should be sent to stdout
.
google
ogle
1