#312. 字符串前缀查找
字符串前缀查找
Prefix String Search
Background
Congcong has been studying string properties recently. He finds many interesting patterns hidden within strings.
Problem Description
Given a string and an integer , consider the prefix string made of the first characters of . Determine if this prefix string appears somewhere else in the original string (i.e., not starting at index ). Assume that the string is not empty and that is in the range .
Input Format
Input is given from standard input in the following format.
The first line contains a string . The second line contains an integer .
Output Format
Output is printed to standard output in the following format.
Output
trueif the prefix string appears elsewhere; otherwise, outputfalse.
Sample
abXYabc
1
true
abXYabc
2
true
abXYabc
3
false
Sample Explanation
For the first sample, the string is "abXYabc" and . The prefix string is "a". It appears again in the original string starting at index , so the output is true.
For the second sample, the string is "abXYabc" and . The prefix string is "ab". It appears again in the original string starting at index , so the output is true.
For the third sample, the string is "abXYabc" and . The prefix string is "abX". It does not appear anywhere else in the original string besides starting at index , so the output is false.
Constraints
Time limit: second, Memory limit: KiB for each test case.