From a85de0f48a6b83de39936d8a2a5418d059929cf8 Mon Sep 17 00:00:00 2001 From: Eunbi An Date: Sun, 15 Oct 2023 19:38:36 +0900 Subject: [PATCH 1/2] add week15 --- ...\354\236\220\353\245\264\352\270\260.java" | 29 +++++++ ...\352\270\210\352\267\270\352\263\241.java" | 81 +++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 "eunbi/week15/\353\241\244\354\274\200\354\235\264\355\201\254\354\236\220\353\245\264\352\270\260.java" create mode 100644 "eunbi/week15/\353\260\251\352\270\210\352\267\270\352\263\241.java" diff --git "a/eunbi/week15/\353\241\244\354\274\200\354\235\264\355\201\254\354\236\220\353\245\264\352\270\260.java" "b/eunbi/week15/\353\241\244\354\274\200\354\235\264\355\201\254\354\236\220\353\245\264\352\270\260.java" new file mode 100644 index 0000000..e0ec469 --- /dev/null +++ "b/eunbi/week15/\353\241\244\354\274\200\354\235\264\355\201\254\354\236\220\353\245\264\352\270\260.java" @@ -0,0 +1,29 @@ +package algorithmStudy; + +import java.util.*; + +class Solution { + public int solution(int[] topping) { + int answer = 0; + Map map1 = new HashMap(); + Map map2 = new HashMap(); + + for(int i : topping) + map1.put(i, map1.getOrDefault(i, 0) + 1); + + for(int i=0; i0) + map1.put(topping[i], map1.get(topping[i]) - 1); + + if(map1.get(topping[i])==0) + map1.remove(topping[i]); + + map2.put(topping[i], map2.getOrDefault(topping[i], 0) + 1); + + if(map1.size()==map2.size()) + answer++; + } + + return answer; + } +} \ No newline at end of file diff --git "a/eunbi/week15/\353\260\251\352\270\210\352\267\270\352\263\241.java" "b/eunbi/week15/\353\260\251\352\270\210\352\267\270\352\263\241.java" new file mode 100644 index 0000000..c9859ea --- /dev/null +++ "b/eunbi/week15/\353\260\251\352\270\210\352\267\270\352\263\241.java" @@ -0,0 +1,81 @@ +package algorithmStudy; + +import java.util.*; + +public class Music{ + private int music_len_ = 0; // À½¾Ç Àç»ý ½Ã°£ + private String melody_ = ""; // Àç»ýµÈ ¸á·Îµð + private String title_ = ""; // ³ë·¡ Á¦¸ñ + private boolean flag_ = false; // Á¶°Ç ¸¸Á· : true, ¸¸Á· x : false + + public Music(String[] s){ + title_ = s[2]; + music_len_ = Integer.parseInt(s[1].substring(3, 5)) - Integer.parseInt(s[0].substring(3, 5)) + 60*(Integer.parseInt(s[1].substring(0, 2)) - Integer.parseInt(s[0].substring(0, 2))); + } + + public void set_melody(String melody){ // Àç»ýµÈ ¸á·Îµð °è»ê + melody_ = melody; + } + + public int get_music_len(){ + return music_len_; + } + + public void set_flag(String m){ + flag_ = melody_.contains(m); + } + + public boolean get_flag(){ + return flag_; + } + + public String get_title(){ + return title_; + } +} + +class Solution { + public String solution(String m, String[] musicinfos) { + String answer = "(None)"; + int max_len = 0; + Music[] music = new Music[musicinfos.length]; + m = convert(m.replace("#", "").length() ,m); + + for(int i=0; i Date: Sun, 15 Oct 2023 22:31:33 +0900 Subject: [PATCH 2/2] add week15 --- ...\354\202\274\352\260\201\355\230\225.java" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "eunbi/week15/\354\240\225\354\210\230\354\202\274\352\260\201\355\230\225.java" diff --git "a/eunbi/week15/\354\240\225\354\210\230\354\202\274\352\260\201\355\230\225.java" "b/eunbi/week15/\354\240\225\354\210\230\354\202\274\352\260\201\355\230\225.java" new file mode 100644 index 0000000..8b0a95d --- /dev/null +++ "b/eunbi/week15/\354\240\225\354\210\230\354\202\274\352\260\201\355\230\225.java" @@ -0,0 +1,25 @@ +package algorithmStudy; + +import java.util.*; + +class Solution { + public int solution(int[][] triangle) { + int answer = 0; + + for(int i=1; i