Subsequence vs. Substring

less than 1 minute read

Just saw a comprehensive definition in an algorithm class

A subsequence of a sequence (for example, an array, linked list, or string), obtained by removing zero or more elements and keeping the rest in the same sequence order.

A subsequence is called a substring if its elements are contiguous in the original sequence.

Updated: