# Leecode String
###### tags: `Leetcode`
## 856. Score of Parentheses
## 22. Generate Parentheses
Time Complexity: $O(2^n)$
Space Complexity: $O(n)$
:::success
結果:Accepted
:::
```python
class Solution:
def generateParenthesis(self, n: int) -> List[str]:
res = []
def helper(cur, l, r):
if l == n and r == n:
res.append(cur)
return
if l < n:
helper(cur+"(", l+1, r)
if l > r:
helper(cur+")", l, r+1)
helper("", 0, 0)
return res
```
## 49. Group Anagrams
用 sorted string 當作 key,原本的 string 當作 value,可節省查找時間
Time Complexity: $O(nmlogm)$
Space Complexity: $O(nm)$
:::success
結果:Accepted
:::
```python
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
result = {}
for s in strs:
t = tuple(sorted(s))
if t in result.keys():
result[t].append(s)
else:
result[t] = [s]
return result.values()
```
## 539. Minimum Time Difference
## 1156. Swap For Longest Repeated Character Substring
## 916. Word Subsets
## 583. Delete Operation for Two Strings
## 767. Reorganize String
## 1081. Smallest Subsequence of Distinct Characters
## 17. Letter Combinations of a Phone Number
## 848. Shifting Letters
## 842. Split Array into Fibonacci Sequence
## 227. Basic Calculator II