Given an integer ‘k’ and a string ‘str’ consisting of characters from English alphabets. The task is to convert all lower case character to uppercase whose ASCII value is co-prime with k.
Input: str = “geeksforgeeks”, k = 4
‘f’ and ‘r’ are the only characters whose ASCII values aren’t co-prime with 4.
Input: str = “Ac”, k = 2
The only lower case character is ‘c’ and ASCII value of ‘c’ is 99 which is co-prime with 2.
- Iterate over all characters in the given string to check whether the current character is lowercase and if it’s ASCII value is co-prime with ‘k’
- To check for co-prime, check that if the gcd of the value with k is ‘1’ or not.
- If the above condition is satisfied then convert that lowercase alphabet to uppercase alphabet.
Below is the implementation of the above approach:
- Check if lowercase and uppercase characters are in same order
- Maximum distinct lowercase alphabets between two uppercase
- Program to display all alphabets from A to Z in uppercase and lowercase both
- Count Uppercase, Lowercase, special character and numeric values
- Minimum number of operations to move all uppercase characters before all lower case characters
- Sub-strings having exactly k characters that have ASCII value greater than p
- Average of ASCII values of characters of a given string
- Program to find the XOR of ASCII values of characters in a string
- Count characters in a string whose ASCII values are prime
- Count pairs of characters in a string whose ASCII value difference is K
- Convert a string to hexadecimal ASCII values
- Convert the ASCII value sentence to its equivalent string
- Find the sum of the ascii values of characters which are present at prime positions
- Find number of substrings of length k whose sum of ASCII value of characters is divisible by k
- Program to find the product of ASCII values of characters in a string
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.