Substring VS Subsequence

Cho Zin Thet
Jan 25, 2021


Substring and Subsequence


Substring is a sub continous part of a string.

(a, b, c, d) has 10 substrings.

(a)(b)(c)(d)(a, b)(b, c)(c, d)(a, b, c)(b, c, d)(a, b, c, d)

Number of substrings in a string = (n * (n + 1) )/ 2 ;


Subsequence is a sub part of a string in order.

There are 15 subsequence in (a, b, c, d) string


Number of subsequence in a string =(2^n)-1;



Cho Zin Thet

Learning javascript and web-development