Score : $500$ points
Given are two strings $s$ and $t$ consisting of lowercase English letters. Determine if there exists an integer $i$ satisfying the following condition, and find the minimum such $i$ if it exists.
contest
include net
, c
, and contest
.Input is given from Standard Input in the following format:
$s$ $t$
If there exists an integer $i$ satisfying the following condition, print the minimum such $i$; otherwise, print -1
.
contest son
10
$t =$ son
is a subsequence of the string contestcon
(the first $10$ characters in $s' =$ contestcontestcontest...
), so $i = 10$ satisfies the condition.
On the other hand, $t$ is not a subsequence of the string contestco
(the first $9$ characters in $s'$), so $i = 9$ does not satisfy the condition.
Similarly, any integer less than $9$ does not satisfy the condition, either. Thus, the minimum integer $i$ satisfying the condition is $10$.
contest programming
-1
$t =$ programming
is not a substring of $s' =$ contestcontestcontest...
. Thus, there is no integer $i$ satisfying the condition.
contest sentence
33
Note that the answer may not fit into a $32$-bit integer type, though we cannot put such a case here.