How to test if one string is a subsequence of another?
This is a weaker condition than being a substring. For example 'iran' is not a substring of 'ireland', but it is a subsequence IRelANd
. The difference is a subsequence doesn't have to be contiguous.
More examples:
- 'indonesia' contains 'india'.
INDonesIA
- 'romania' contains 'oman'.
rOMANia
- 'malawi' contains 'mali'.
MALawI
Movitation: My friends like word games. Yesterday we played 'countries within countries'. I am curious if there are any pairs we missed.
Edit: If you aren't familiar with the mathematical definition of subsequence
A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements