A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/dsa/string-subsequence-substring/ below:

Subsequence and Substring - GeeksforGeeks

A substring is a contiguous part of a string, i.e., a string inside another string.

In general, for an string of size n, there are n*(n+1)/2 non-empty substrings. For example, Consider the string "geeks", There are 15 non-empty substrings. The subarrays are:

g, ge, gee, geek, geeks,
e, ee, eek, eeks,
e, ek, eks,
k, ks,
s

A subsequence is a sequence that can be derived from another sequence by removing zero or more elements, without changing the order of the remaining elements.

More generally, we can say that for a sequence of size n, we can have ((2^n)-1) non-empty sub-sequences in total. For the same above example, there are 31 sub-sequences. They are:

g, e, e, k, s,
ge, ge, gk, gs, ee, ek, es, ek, es, ks,
gee, gek, ges, gek, ges, gks, eek, ees, eks, eks,
geek, gees, eeks, geks, geks,
geeks


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4