Given an input string with lowercase letters, the task is to write a python program to identify the repeated characters in the string and capitalize them.
Input: programming language
Output: pRoGRAMMiNG lANGuAGe
Explanation: r,m,n,a,g are repeated elements
Input: geeks for geeks
Output: GEEKS for GEEKS
Expalanation: g,e,k,s are repeated elements
- We have to keep the character of a string as a key and the frequency of each character of the string as a value in the dictionary.
- Traverse the string and check the frequency of each character using a dictionary if the frequency of the character is greater than one then change the character to the uppercase using the upper() function.
GEEKS for GEEKS
Time Complexity: O(n)
Space Complexity: O(n)
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.