Skip to Content
C++ Data Structures and Algorithms
book

C++ Data Structures and Algorithms

by Wisnu Anggoro
April 2018
Intermediate to advanced content levelIntermediate to advanced
322 pages
6h 57m
English
Packt Publishing
Content preview from C++ Data Structures and Algorithms

Checking whether a string is a subsequence of another string

We have successfully created code to generate subsequences of a string. Now we are going to create a C++ code to check if a string is a subsequence of another string. To do so, we will compare the character of two strings from the last character (the reason we compare from the last character of the string is the simplicity of checking the index against 0, rather than keeping track of the final index of both strings).

Suppose str1 is a subsequence of a string of str2, x is the index of str1, and y is the index of str2. It means that we will compare str1[x - 1] with str2[y -1]If matched, continue until all suspected subsequence string characters have been checked. If not, compare ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Data Structures and Algorithms Using C++

Data Structures and Algorithms Using C++

Ananda Rao Akepogu, Radhika Raju Palagiri
C++ Data Structures and Algorithm Design Principles

C++ Data Structures and Algorithm Design Principles

John Carey, Anil Achary, Shreyans Doshi, Payas Rajan
C++ Plus Data Structures, 6th Edition

C++ Plus Data Structures, 6th Edition

Nell Dale, Chip Weems, Tim Richards

Publisher Resources

ISBN: 9781788835213Supplemental Content