GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/java/937_Reorder_Log_Files.java at master · qiyuangong/leetcode Expand file tree/ Copy path937_Reorder_Log_Files.javaMore file actions 19 lines (18 loc) · 687 Bytes / Copy path937_Reorder_Log_Files.javaFile metadata and controls19 lines (18 loc) · 687 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import java.util.List; class Solution { public String[] reorderLogFiles(String[] logs) { Arrays.sort(logs, (log1, log2) -> { String[] split1 = log1.split(" ", 2); String[] split2 = log2.split(" ", 2); boolean isDigit1 = Character.isDigit(split1[1].charAt(0)); boolean isDigit2 = Character.isDigit(split2[1].charAt(0)); if (!isDigit1 && !isDigit2) { int cmp = split1[1].compareTo(split2[1]); if (cmp != 0) return cmp; return split1[0].compareTo(split2[0]); } return isDigit1 ? (isDigit2 ? 0 : 1) : -1; }); return logs; } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |