Professional Documents
Culture Documents
Strings
Strings
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