C++ program to check whether a string2 can be formed from string1
In general, a string (string 2) can be formed from another string (string 1) if string1 can contain all the characters of string2 (Repetition and Case sensitivity are also considered).
Example - 1
Yes,String2 can be formed from String1.
Example - 2
No, because ‘l’ comes 3 times in ‘Helll’ while there is only two ‘l’ present in IncludeHelp.
Example - 3
No, ‘i’ is in lower case in String2 while in String1, ‘I’ is in upper case (Case sensitive).
Hope you get all the points to be considered through above Examples.
Now come to the program, for faster and effective result we use concept of Count Array.
To learn about Count Array (implementation and use) go through the program C++ program to find the frequency of a character in a string using Count Array.
Program to check whether a string2 can be formed from string1 in C++
Output
need an explanation for this answer? contact us directly to get an explanation for this answer