0% found this document useful (0 votes)
7 views2 pages

String Manipulation Algorithms Guide

Uploaded by

Kartik Motkule
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

String Manipulation Algorithms Guide

Uploaded by

Kartik Motkule
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Reverse a String
Input: "hello" → Output: "olleh"

2. Check if a String is a Palindrome


Input: "madam" → Output: true

3. Count and return the number of vowels in a string


Input: "interview" → Output: 4

4. Check if two strings are anagrams


Input: "listen", "silent" → Output: true

5. Remove all duplicates from a string


Input: "programming" → Output: "progamin"

6. Find the first non-repeating character


Input: "swiss" → Output: "w"

7. Implement strstr() function (index of substring)


Input: haystack = "hello", needle = "ll" → Output: 2

8. Convert Roman Numerals to Integer


Input: "XIV" → Output: 14

Medium Level

9. Longest Common Prefix among an array of strings


Input: ["flower","flow","flight"] → Output: "fl"

10. Check if a string is a valid palindrome ignoring non-alphanumeric characters


Input: "A man, a plan, a canal: Panama" → Output: true

11. Group anagrams together


Input: ["eat", "tea", "tan", "ate", "nat", "bat"] → Output:
[["eat","tea","ate"],["tan","nat"],["bat"]]

12. ZigZag Conversion


Input: "PAYPALISHIRING", numRows = 3 → Output: "PAHNAPLSIIGYIR"

13. Longest Substring Without Repeating Characters


Input: "abcabcbb" → Output: 3 ("abc")

14. String Compression (e.g., aabcccccaaa → a2b1c5a3)


Return original string if compression doesn’t reduce the length.

15. Check if a string is a rotation of another string


Input: s1 = "waterbottle", s2 = "erbottlewat" → Output: true

Hard Level

16. Minimum window substring


Input: s = "ADOBECODEBANC", t = "ABC" → Output: "BANC"
17. Word Break Problem (Can the string be segmented into dictionary words?)
Input: "leetcode", dict = ["leet", "code"] → Output: true

18. Longest Palindromic Substring


Input: "babad" → Output: "bab" or "aba"

19. Find All Anagrams in a String


Input: s = "cbaebabacd", p = "abc" → Output: [0, 6]

20. Multiply two large numbers given as strings


Input: num1 = "123", num2 = "456" → Output: "56088"

You might also like