๐ค String Problems
Welcome to the String section of JDCodebase!
Strings are sequences of characters used in nearly every coding task. They are immutable in JavaScript, meaning any operation on a string returns a new one. Mastering string manipulation is key for interviews and daily coding.
๐ Common String Methods in JavaScript
str.length
โ returns the number of charactersstr.charAt(i)
orstr[i]
โ access character at indexstr.toLowerCase()
/toUpperCase()
โ case conversionstr.includes(sub)
โ check for substringstr.indexOf(char)
โ find first index of a characterstr.split(" ")
โ convert string into an array of wordsstr.trim()
โ remove whitespace from both endsstr.replace(a, b)
โ replace substringstr.slice(start, end)
โ extract substring by indexstr.substring(start, end)
โ similar to slice, works without negatives
๐ง You'll Learn
- Character frequency and counting logic
- String reversal, palindrome checks, and substrings
- Two-pointer techniques on strings
๐ Problems List
- Count the Number of Consistent Strings (#1684)
- Defanging an IP Address (#1108)
- Goal Parser Interpretation (#1678)
- To Lower Case (#709)
- Reverse String (#344)
- Valid Palindrome (#125)
- String Compression (#443)
- Is Subsequence (#392)
- Merge Strings Alternately (#1768)
- Find the Index of the First Occurrence in a String (#28)
- Reverse Vowels of a String (#345)
- Reverse String II (#541)
- Reverse Words in a String III (#557)
- Count Binary Substrings (#696)
- Shortest Distance to a Character (#821)
- Reverse Only Letters (#917)