본문 바로가기

코딩테스트5

[ LeetCode ] 49번 Group Anagrams leetcode.com/problems/group-anagrams/ Group Anagrams - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com class Solution: def groupAnagrams(self, strs: List[str]) -> List[List[str]]: ana = collections.defaultdict(list) for word in strs: ana[''.join(sorted(word))].append(word) return a.. 2021. 4. 19.
[ LeetCode ] 819번 Most Common Word leetcode.com/problems/most-common-word/ Most Common Word - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com class Solution: def mostCommonWord(self, paragraph: str, banned: List[str]) -> str: #data cleansing words = [word for word in re.sub('[^\w]',' ',paragraph).lower().split() if .. 2021. 4. 18.
[ LeetCode ] 937번 Reorder Data in Log Files 풀이 leetcode.com/problems/reorder-data-in-log-files/ Reorder Data in Log Files - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com class Solution: def reorderLogFiles(self, logs: List[str]) -> List[str]: letters, digits = [],[] for log in logs: if log.split()[1].isdigit(): digits.append(.. 2021. 4. 16.
[ LeetCode ] 344번 Reverse String leetcode.com/problems/reverse-string/ Reverse String - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com class Solution: def reverseString(self, s: List[str]) -> None: s.reverse() 2021. 4. 15.