![]() |
VOOZH | about |
In C++, strings are sequences of characters that are used to store text data which can be in both uppercase and lowercase format. In this article, we will learn how we can compare two case-insensitive strings in C++.
Example:
Input:
string1 = "WELCOME TO GEEKS FOR GEEKS"
string2 = "welcome to geeks for geeks"
Output:
Strings are equal
To compare two case-insensitive strings in C++, we have to temporarily convert both strings to either lowercase or uppercase. After that, we can compare them to get the result which will not depend upon the case of the characters.
The following program illustrates how we can compare two case-insensitive strings in C++:
Strings are equal
Time complexity: O(N), where N denotes the length of the two strings.
Auxiliary Space: O(1)