Last active
September 14, 2019 19:41
-
-
Save alphaCoder/b97167fea232669331db8e1cd0064456 to your computer and use it in GitHub Desktop.
Re order log files
This file contains hidden or 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
class Solution: | |
def reorderLogFiles(self, logs: List[str]) -> List[str]: | |
digits = [] | |
letters = [] | |
for log in logs: | |
if log.split()[1].isdigit(): | |
digits.append(log) | |
else: | |
letters.append(log) | |
letters.sort(key=lambda x: x.split()[0]) | |
letters.sort(key=lambda x: x.split()[1:]) | |
return letters + digits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment