From 2cc73b23e51dfaea6a84ece1e271ad0e52b4e9b8 Mon Sep 17 00:00:00 2001 From: mong3125 Date: Fri, 3 May 2024 00:07:52 +0900 Subject: [PATCH] =?UTF-8?q?=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=98=EB=A8=B8?= =?UTF-8?q?=EC=8A=A4=20=EC=A0=84=ED=99=94=EB=B2=88=ED=98=B8=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20java=20solution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\355\230\270\353\252\251\353\241\235.java" | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 "mong3125/\355\225\264\354\213\234.P_\354\240\204\355\231\224\353\262\210\355\230\270\353\252\251\353\241\235.java" diff --git "a/mong3125/\355\225\264\354\213\234.P_\354\240\204\355\231\224\353\262\210\355\230\270\353\252\251\353\241\235.java" "b/mong3125/\355\225\264\354\213\234.P_\354\240\204\355\231\224\353\262\210\355\230\270\353\252\251\353\241\235.java" new file mode 100644 index 0000000..ebebf49 --- /dev/null +++ "b/mong3125/\355\225\264\354\213\234.P_\354\240\204\355\231\224\353\262\210\355\230\270\353\252\251\353\241\235.java" @@ -0,0 +1,20 @@ +import java.util.HashSet; + +class Solution { + public boolean solution(String[] phone_book) { + + HashSet set = new HashSet<>(); + + for (String phoneNum : phone_book) { + set.add(phoneNum); + } + + for (String phoneNum : phone_book) { + for (int i = 0; i < phoneNum.length(); i++) { + if (set.contains(phoneNum.substring(0, i))) return false; + } + } + + return true; + } +} \ No newline at end of file