프로그래머스2 [프로그래머스] 문자열 다루기 기본 class Solution { public boolean solution(String s) { return isValidLength(s) && isMatchPattern(s); } private boolean isValidLength(String s) { return s.length() == 4 || s.length() == 6; } private boolean isMatchPattern(String s) { try { int n = Integer.parseInt(s); return true; } catch (Exception e) { return false; } } } 개인적으로 깔끔하게 풀었다고 생각해서 기록하는 중 ᜊʕ ྀི ܸ. . .ܸ ྀིʔᜊ CS/자료구조&알고리즘 2024. 1. 12. [프로그래머스] 파일명 정렬 : JAVA 초기 제출 코드 import java.util.*; class Solution { public String[] solution(String[] files) { Arrays.sort(files, new Comparator() { @Override public int compare(String s1, String s2) { FileName fileName1 = exportFileName(s1); FileName fileName2 = exportFileName(s2); if (fileName1.getHead().toLowerCase().compareTo(fileName2.getHead().toLowerCase()) > 0) { return 1; } else if (fileName1.getHead().toLow.. CS/자료구조&알고리즘 2024. 1. 11. 이전 1 다음 728x90 반응형