![]() |
VOOZH | about |
Given a string of both uppercase and lowercase alphabets, the task is to print the string with alternate occurrences of any character dropped(including space and consider upper and lowercase as same).
Examples:
Input : It is a long day Dear. Output : It sa longdy ear. Print first I and then ignore next i. Similarly print first space then ignore next space. Input : Geeks for geeks Output : Geks fore
Asked in: Microsoft
As we have to print characters in an alternate manner, so start traversing the string and perform following two steps:-
Implementation:
Geks fore It sa longdy ear
Time complexity : O(n)
Auxiliary Space : O(n)