From 7e91c9e6c795a9b5f4d2648041f806fdcef7228c Mon Sep 17 00:00:00 2001 From: mong3125 Date: Tue, 16 Apr 2024 00:01:54 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=98?= =?UTF-8?q?=EB=A8=B8=EC=8A=A4=20=EC=8A=A4=ED=82=AC=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...355\205\214\354\212\244\355\212\2701.java" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "mong3125/\353\254\270\354\236\220\354\227\264/PS\354\212\244\355\202\254\354\262\264\355\201\254\355\205\214\354\212\244\355\212\2701.java" diff --git "a/mong3125/\353\254\270\354\236\220\354\227\264/PS\354\212\244\355\202\254\354\262\264\355\201\254\355\205\214\354\212\244\355\212\2701.java" "b/mong3125/\353\254\270\354\236\220\354\227\264/PS\354\212\244\355\202\254\354\262\264\355\201\254\355\205\214\354\212\244\355\212\2701.java" new file mode 100644 index 0000000..c5d0cf5 --- /dev/null +++ "b/mong3125/\353\254\270\354\236\220\354\227\264/PS\354\212\244\355\202\254\354\262\264\355\201\254\355\205\214\354\212\244\355\212\2701.java" @@ -0,0 +1,24 @@ +package 문자열; + +public class PS스킬체크테스트1 { + class Solution { + public boolean solution(String s) { + boolean answer = false; + + int len_s = s.length(); + if (len_s != 4 && len_s != 6) return false; + + for (int i = 0; i < len_s; i++) { + char c = s.charAt(i); + if (c >= '0' && c <= '9') { + answer = true; + } else { + answer = false; + break; + } + } + + return answer; + } + } +} From 9a3eb2fcbbb2f7952e5668c2959b2bcd79453a24 Mon Sep 17 00:00:00 2001 From: mong3125 Date: Tue, 16 Apr 2024 00:01:58 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=98?= =?UTF-8?q?=EB=A8=B8=EC=8A=A4=20=EC=8A=A4=ED=82=AC=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...355\205\214\354\212\244\355\212\2702.java" | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 "mong3125/\353\254\270\354\236\220\354\227\264/PS\354\212\244\355\202\254\354\262\264\355\201\254\355\205\214\354\212\244\355\212\2702.java" diff --git "a/mong3125/\353\254\270\354\236\220\354\227\264/PS\354\212\244\355\202\254\354\262\264\355\201\254\355\205\214\354\212\244\355\212\2702.java" "b/mong3125/\353\254\270\354\236\220\354\227\264/PS\354\212\244\355\202\254\354\262\264\355\201\254\355\205\214\354\212\244\355\212\2702.java" new file mode 100644 index 0000000..bd8c20b --- /dev/null +++ "b/mong3125/\353\254\270\354\236\220\354\227\264/PS\354\212\244\355\202\254\354\262\264\355\201\254\355\205\214\354\212\244\355\212\2702.java" @@ -0,0 +1,26 @@ +package 문자열; + +import java.util.*; + +public class PS스킬체크테스트2 { + class Solution { + public int[] solution(String s) { + int[] answer = new int[s.length()]; + + HashMap alphabet = new HashMap<>(); + + for (int i = 0; i < s.length(); i++) { + char now = s.charAt(i); + if (alphabet.containsKey(now)) { + answer[i] = i - alphabet.get(now); + } else { + answer[i] = -1; + } + + alphabet.put(now, i); + } + + return answer; + } + } +}