#C7069. Subsequence Checker
Subsequence Checker
Subsequence Checker
Given two strings a
and b
, determine whether a
is a subsequence of b
. A subsequence is obtained from a string by deleting zero or more characters without changing the order of the remaining characters. Formally, you need to check if all characters of a
appear in b
in the same order. In other words, if we denote the characters of a
as \(a_1, a_2, \ldots, a_n\) then there exists indices \(1 \le i_1 < i_2 < \cdots < i_n \le m\) (where \(m\) is the length of b
) such that \(a_1 = b_{i_1}, a_2 = b_{i_2}, \ldots, a_n = b_{i_n}\).
inputFormat
The input consists of two lines. The first line contains the string a
and the second line contains the string b
.
outputFormat
Print True
if a
is a subsequence of b
; otherwise, print False
.
abc
ahbgdc
True