๐Ÿ”ค 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 characters
  • str.charAt(i) or str[i] โ€” access character at index
  • str.toLowerCase() / toUpperCase() โ€” case conversion
  • str.includes(sub) โ€” check for substring
  • str.indexOf(char) โ€” find first index of a character
  • str.split(" ") โ€” convert string into an array of words
  • str.trim() โ€” remove whitespace from both ends
  • str.replace(a, b) โ€” replace substring
  • str.slice(start, end) โ€” extract substring by index
  • str.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

  1. Count the Number of Consistent Strings (#1684)
  2. Defanging an IP Address (#1108)
  3. Goal Parser Interpretation (#1678)
  4. To Lower Case (#709)
  5. Reverse String (#344)
  6. Valid Palindrome (#125)
  7. String Compression (#443)
  8. Is Subsequence (#392)
  9. Merge Strings Alternately (#1768)
  10. Find the Index of the First Occurrence in a String (#28)
  11. Reverse Vowels of a String (#345)
  12. Reverse String II (#541)
  13. Reverse Words in a String III (#557)
  14. Count Binary Substrings (#696)
  15. Shortest Distance to a Character (#821)
  16. Reverse Only Letters (#917)