#K57247. String Transformation via Reversal and Concatenation
String Transformation via Reversal and Concatenation
String Transformation via Reversal and Concatenation
You are given two integers num1 and num2. The task is to determine if the string representation of num2 is a substring of either of the two strings formed by concatenating num1 and its reversal in different orders.
Let \( a = \text{str}(\text{num1}) \) and \( a^R \) be the reversal of \( a \). Define the two candidate strings as follows:
[ c_1 = a + a^R \quad \text{and} \quad c_2 = a^R + a ]
Your task is to print True
if num2 (as a string) appears as a substring in either \( c_1 \) or \( c_2 \); otherwise, print False
.
inputFormat
The input consists of a single line containing two space-separated integers num1 and num2.
For example:
123 321
outputFormat
Print True
if the string representation of num2 is a substring of either str(num1) + reverse(str(num1))
or reverse(str(num1)) + str(num1)
. Otherwise, print False
.
123 321
True