Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Character Manipulation

1. Print every alternate letter in Uppercase.


Example: “chimpanzee” -> “ChImPaNzEe”.
2. Print characters of odd index first and then even index.
Example: “chimpanzee” -> “cipne” “hmaze”
3. Print index of character in alphabet series.
Example: (i) ‘A’ -> 1 (ii) ‘E’ -> 5
4. Convert to Caesar Cipher, take shift = 7
Example: “beautiful” -> “ilhbapmbs”
5. Print take two characters, print its difference:
Example: (i) ‘A’ ‘E’ -> 4 (ii) ‘B’ ‘C’ -> 1 (iii) ‘Z’ ‘Z’ -> 0
6. Convert the characters which are lowercase to uppercase and vice versa.
Example: “Bang BooM” -> “bANG bOOm”
7. Calculate weight of string
Example: “Cabb” -> 3 + 1 + 2 + 2 = 8
8. Calculate weight of strings without including vowels
Example: “Cabb” -> 3 + 0 + 2 + 2 = 7
9. Find number according to pattern
Example 1: “BADE” -> | B - E | + | A - D | = | 2 - 5 | + | 1 - 4| = 3 + 3 = 6
Example 2: “BACDE” -> | B - E | + C + | A - D | = | 2 - 5 | + 3 + | 1 - 4| = 3 + 3 + 3 = 9

BASICS
1. Find the minimum and maximum in an array
2. Reverse a word
3. Program to remove vowels from a String
Input : welcome to geeksforgeeks
Output : wlcm t gksfrgks
4. Remove characters from a string
Input : String -> “Doraemon”, Character -> “o”
Output: “Draemn”
5. Check if given string is an integer
6. Calculate sum of all numbers present in a string
7. Swap first and last letter of a string (take sentence)
8. Check if parentheses are balanced
9. Check if string is a palindrome (string that reads forwards and backwards, ex - dad)

COUNTING
1. Count number of uppercase, lowercase, special character and numeric values.
2. Count words present in a string
3. Count number of vowels and consonants in a String
Input : “JAVA”
Output : 2 vowels 2 consonants
STRING SPLIT
1. Get the first letter of each word in a string
2. Reverse words in string without reversing their order. Ex: “Dog is best” -> “goD si tseb”
3. Find the smallest and largest word in a string (sentence).

HASH TABLE

1. Find characters which are present in first string but not present in second string.
Input: “Hello” “Mello”
Output: “M”
2. How many characters match in two strings?
3. Print duplicate characters from String (trick: convert to lowercase)
Input : “Java”
Output: “a”
4. Find the word which are present in first string but not present in second string.
5. Find the characters that are unique in a string, i.e. have only one occurence.
6. Print frequency of each character
Input : How Good GOD Is.
Output :
Character = Frequency = 3 (character - space)
Character = . Frequency = 1
Character = D Frequency = 1
Character = G Frequency = 2
Character = H Frequency = 1
Character = I Frequency = 1
Character = O Frequency = 1
Character = d Frequency = 1
Character = o Frequency = 3
Character = s Frequency = 1
Character = w Frequency = 1

STRING ROTATION

1. Caesar Cipher - Write methods for - “encoder” and “decoder”. Offset is entered as input.
2. Check if a given string is a rotation of another

STRING MANIPULATION

1. Compress a string. Examples:


a. “AAABBBBBCC” -> “A3B4C2”
b. “ABBBCC” -> “AB3C2” (Hint: If character is having 1 val, then don’t print 1)
c. “AABBAACCB” -> “A2B2A2C2B”
2. URLify -> Replace all spaces in a string with “%20”
Example: “Mr John Smith” -> “Mr%20John%20Smith”
3. Is one string a permutation of other?
Example: (i) “ghost” “gstoh” -> True (ii) “dog” “gode” -> False
4. Is a string substring of other?
Example: (i) “HelloWorld” “ell” -> True (ii) “Coding” “din” -> True (iii) “Cracking”
“ric” -> False
5. Find the edit distance of two strings.

You might also like