DEV Community

vivek
vivek

Posted on

Mastering Competitive Coding: String

Easy level questions

  1. Word Break:

    • Input: s = "leetcode", wordDict = ["leet", "code"]
    • Output: True
    • Explanation: "leetcode" can be segmented into "leet" and "code".
  2. Longest Palindromic Substring:

    • Input: s = "babad"
    • Output: "bab" or "aba"
    • Explanation: Both "bab" and "aba" are valid longest palindromic substrings.
  3. Regular Expression Matching:

    • Input: s = "aa", p = "a*"
    • Output: True
    • Explanation: Pattern "a*" matches zero or more occurrences of 'a'.
  4. Letter Combinations of a Phone Number:

    • Input: digits = "23"
    • Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]
    • Explanation: Corresponding letters for digits 2 and 3 are "abc" and "def" respectively.
  5. Valid Palindrome II:

    • Input: s = "abca"
    • Output: True
    • Explanation: By deleting 'b', the resulting string "aca" is a palindrome.
  6. Group Anagrams:

    • Input: strs = ["eat", "tea", "tan", "ate", "nat", "bat"]
    • Output: [["bat"], ["nat","tan"], ["ate","eat","tea"]]
    • Explanation: Anagrams are grouped together.
  7. Minimum Window Substring:

    • Input: s = "ADOBECODEBANC", t = "ABC"
    • Output: "BANC"
    • Explanation: The minimum window substring containing all characters from t is "BANC".
  8. Decode String:

    • Input: s = "3[a]2[bc]"
    • Output: "aaabcbc"
    • Explanation: Decode the string by repeating substrings inside brackets.
  9. Permutations:

    • Input: nums = [1,2,3]
    • Output: [[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]
    • Explanation: All possible permutations of the input list.
  10. Add Binary:

    • Input: a = "11", b = "1"
    • Output: "100"
    • Explanation: Binary addition of "11" and "1" results in "100".

Top comments (0)