[ Python ] 파이썬 자리수마다 더하기
·
Archive/Develop
while x>0: sum += x % 10 x = x//10 print(sum) for i in str(x): sum+= int(i) print(sum) 두번째 방법은 파이썬이라서 가능한 것 같다. 직관적이라서 좋다!
[ LeetCode ] 819번 Most Common Word
·
Archive/Develop
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 ..
[ LeetCode ] 937번 Reorder Data in Log Files 풀이
·
Archive/Develop
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(..
[ LeetCode ] 344번 Reverse String
·
Archive/Develop
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()