-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e27f147
commit 248c757
Showing
7 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Solution: | ||
def reverseString(self, s: List[str]) -> None: | ||
s.reverse() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Solution: | ||
def groupAnagrams(self, strs: List[str]) -> List[List[str]]: | ||
anagrams = collections.defaultdict(list) | ||
|
||
for word in strs: | ||
anagrams[''.join(sorted(word))].append(word) | ||
return anagrams.values() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class Solution: | ||
def longestPalindrome(self, s: str) -> str: | ||
def expand(left: int, right: int) -> str: | ||
while left >= 0 and right <= len(s) and s[left] == s[right-1]: | ||
left -= 1 | ||
right += 1 | ||
return s[left+1:right-1] | ||
|
||
if len(s) < 2 or s == s[::-1]: | ||
return s | ||
|
||
result = '' | ||
|
||
for i in range(len(s)-1): | ||
result = max(result, expand(i, i+1), expand(i, i+2), key=len) | ||
|
||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Solution: | ||
def mostCommonWord(self, paragraph: str, banned: List[str]) -> str: | ||
words = [word for word in re.sub('[^\w]', ' ', paragraph).lower().split() if word not in banned] | ||
|
||
counts = collections.Counter(words) | ||
|
||
return counts.most_common(1)[0][0] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Solution: | ||
def reorderLogFiles(self, logs: List[str]) -> List[str]: | ||
letters, digits = [], [] | ||
for log in logs: | ||
if log.split()[1].isdigit(): | ||
digits.append(log) | ||
else: | ||
letters.append(log) | ||
|
||
letters.sort(key=lambda x: (x.split()[1:], x.split()[0])) | ||
return letters + digits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Helpful Things | ||
|
||
## Python Regex Module | ||
|
||
[Python Regex](https://www.w3schools.com/python/python_regex.asp) | ||
|
||
```python3 | ||
import re | ||
|
||
re.findAll() | ||
re.search() | ||
re.split() | ||
re.sub() | ||
``` | ||
|
||
## Python Lambda | ||
|
||
[Python Lambda](https://www.w3schools.com/python/python_lambda.asp) | ||
|
||
## Python String | ||
|
||
[Python String Method](https://www.w3schools.com/python/python_strings_methods.asp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
|
||
파이썬 문자열 조작 | ||
|
||
> 125, 344 | ||
> 125, 344, 937, 819, 49, 5 | ||
## 자료구조 | ||
|
||
|