Strings
In this lesson, we'll discuss common string terms before moving onto problems.
We'll cover the following...
String
A string is a sequence of characters; hence it can be represented using an array of characters.
C++ also has a string
type that can be used instead of char[]
.
First, let’s go over some common terms used in programming competitions for strings.
Anagram
The anagram of a string is obtained by rearranging the letters in the string.
For example: evil
is an anagram of live
, other anagrams are leiv
and vile
.
Whereas lie
is not because we removed v
.
Substring
Substring is a contiguous sequence of characters within a string. Analogous to subarray in arrays.
For example: for the string competitive
comp
, tive
, and pet
are substrings. cope
is not because it’s not contiguous in competitive
.
Correspondingly, there are ...