[LeetCode] 937. Reorder Data in Log Files
2021. 1. 4. 22:30ㆍProblem Solving/LeetCode
https://leetcode.com/problems/reverse-string/submissions/
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 reorderLogFiles(self, logs: List[str]) -> List[str]: char_log: str = [] int_log: str = [] # 문자, 숫자로그 판별 for s in logs: if s.split()[1].isdigit(): int_log.append(s) else: char_log.append(s) char_log.sort(key=lambda x: (x.split()[1:], x.split()[0])) return char_log + int_log

람다 표현식을 사용했다.
이 풀이에 쓰인 파이썬 메소드
책 정보
![]() |
|
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
[LeetCode] 5. Longest Palindromic Substring (0) | 2021.01.07 |
---|---|
[LeetCode] 49. Group Anagrams (0) | 2021.01.06 |
[LeetCode] 819. Most Common Word (0) | 2021.01.05 |
[LeetCode] 344. Reverse String (0) | 2021.01.04 |
[LeetCode] 125. Valid Palindrome (0) | 2021.01.04 |