Does the original string count as a substring of itself?

1.6k Views Asked by At

This is a strange question but is the whole string considered a substring of itself? Ie: String "cheesecake" has a substring "cheesecake".

1

There are 1 best solutions below

0
vamsi krishna On

A string is a substring of itself. Wikipedia says the same.

Also, if you consider "string" as an amalgamation of set of characters, by definition of set - every set is a subset of itself.

Hence the answer - YES.

https://en.wikipedia.org/wiki/Substring