DSA - Data Structures and Algorithms
-
String Manipulation
-
Reverse a String
- 2 pointers: Start and End or Left and Right
-
Algorithm:
- Initialize two pointers: one at the start and one at the end of the list. Start=0 and End=len(string)-1
- Repeat until start < end. Swap the character of start and end. Increment start, decrement end.
- After loop ends, string is reversed.
- Return or print the reversed string.
-
Time Complexity: O(n)
- Check if a String is a Palindrome
- Count Vowels and Consonants
- Find the First Non-Repeating Character
- Anagram Check
- String Compression
- Longest Substring Without Repeating Characters
- Capitalize First Letter Each Word In a String
- Count Occurrences of a Substring
-
Array Manipulation