Leet code practice question
Leet code practice question
2. Decode String
💡 Problem:
Given an encoded string, return its decoded form.
The encoding rule is: k[encoded_string], where encoded_string inside the
brackets is repeated k times.
You may assume that the input string is always valid.
🔹 Example:
Input: s = "3[a]2[bc]"
Output: "aaabcbc"
🔹 Constraints:
1 <= s.length <= 30
s contains only digits, square brackets, and lowercase English
letters.
3. Group Anagrams
💡 Problem:
Given an array of strings strs, group anagrams together.
An anagram is a word or phrase formed by rearranging the letters of a different
word.
🔹 Example:
Input: strs = ["eat","tea","tan","ate","nat","bat"]
Output: [["bat"],["nat","tan"],["ate","eat","tea"]]
🔹 Constraints:
1 <= strs.length <= 10^4
strs[i] consists of lowercase English letters.
5. Zigzag Conversion
💡 Problem:
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of
rows.
You need to return the converted string when read row-wise.
🔹 Example:
Input: s = "PAYPALISHIRING", numRows = 3
Output: "PAHNAPLSIIGYIR"
Explanation:
P A H N
APLSIIG
Y I R
🔹 Constraints:
1 <= s.length <= 1000
1 <= numRows <= 1000