Day 4: String Manipulation – Interview Questions
1. Reverse a string without using built-in reverse()
Input: "Shaivi"
Output: "iviahS"
2. Check if a string is a palindrome
Input: "madam" → True, "hello" → False
3. Count vowels and consonants in a string
Input: "Interview" → Vowels: 4, Consonants: 5
4. Find the most frequent character in a string
Input: "programming" → Output: "g"
5. Remove duplicate characters from a string
Input: "Shaiphali" → Output: "Shaipli"
6. Capitalize the first letter of every word
Input: "hello world" → Output: "Hello World"
7. Check if two strings are anagrams
Input: "listen", "silent" → True
8. Compress a string using character counts
Input: "aaabbc" → Output: "a3b2c1"
9. Remove all whitespaces from a string
Input: "a b c d" → Output: "abcd"
10. Count the number of words in a sentence
Input: "Python is awesome" → Output: 3