diff --git a/Basic_Of_Algorithm/src/Today_22_05_19/menuRenew.java b/Basic_Of_Algorithm/src/Today_22_05_19/menuRenew.java new file mode 100644 index 0000000..20d1cf6 --- /dev/null +++ b/Basic_Of_Algorithm/src/Today_22_05_19/menuRenew.java @@ -0,0 +1,75 @@ +package Today_22_05_19; + +import java.util.HashMap; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; + +public class menuRenew { + + static HashMap map = new HashMap<>(); + static ArrayList answerList = new ArrayList<>(); + + public static void main(String[] args) { + + String [] orders = {"ABCFG", "AC", "CDE", "ACDE", "BCFG", "ACDEH"}; + int [] course = {2,3,4}; + + for(int i=0;i maxValue = new ArrayList<>(map.values()); + int max = Collections.max(maxValue); + if(max>1) { + for(String key : map.keySet()) { + if(map.get(key)==max) { + answerList.add(key); + } + } + } + } + + + map.clear(); + } + + Collections.sort(answerList); + + String[]answer = new String[answerList.size()]; + + for(int i=0;i> map = new HashMap<>(); + + + public static void main(String[] args) { + + String [] info = {"java backend junior pizza 150","python frontend senior chicken 210","python frontend senior chicken 150","cpp backend senior pizza 260","java backend junior chicken 80","python backend senior chicken 50"}; + String [] query = {"java and backend and junior and pizza 100","python and frontend and senior and chicken 200","cpp and - and senior and pizza 250","- and backend and senior and - 150","- and - and - and chicken 100","- and - and - and - 150"}; + int [] answer = new int[query.length]; + + for(String str : info) { + String []temp = str.split(" "); + dfs(temp,"",0); + } + + for(String key:map.keySet()) { + Collections.sort(map.get(key)); + } + + for(int i =0;i list = map.get(now); + + int score = Integer.parseInt(infoScore); + + int start = 0, end = list.size()-1; + + while(start<=end) { + + int mid = (start+end)/2; + + if(list.get(mid)()); + } + map.get(now).add(Integer.parseInt(temp[4])); + return; + } + + dfs(temp,now+"-",count+1); + dfs(temp,now+temp[count],count+1); + + + + + } + +} diff --git a/Basic_Of_Algorithm/src/Today_22_05_19/soosick.java b/Basic_Of_Algorithm/src/Today_22_05_19/soosick.java new file mode 100644 index 0000000..db211b1 --- /dev/null +++ b/Basic_Of_Algorithm/src/Today_22_05_19/soosick.java @@ -0,0 +1,85 @@ +package Today_22_05_19; + +import java.util.*; + +public class soosick { + + static long answer = 0; + static ArrayList numList = new ArrayList<>(); + static ArrayList opList = new ArrayList<>(); + static char [] op = {'+','-','*'}; + static boolean []visited = new boolean[3]; + + public static void main(String[] args) { + + String expression = "100-200*300-500+20"; + + String num = ""; + for(int i=0;i='0' && ch <= '9') { + num += ch; + }else { + numList.add(Long.parseLong(num)); + num=""; + opList.add(ch); + } + } + + numList.add(Long.parseLong(num)); + + dfs(new char[3],0); + + System.out.println(answer); + } + + static Long change(char ch , long a, long b) { + if(ch=='+') return a + b; + else if(ch=='*') return a * b; + else if(ch=='-') return a - b; + else return (long)0; + } + + static void dfs(char[]p,int count) { + + if(count==3) { + ArrayList numArr = new ArrayList<>(numList); + ArrayList opArr = new ArrayList<>(opList); + + for(int i=0;i> singoList = new HashMap<>(); + //나를 신고한 사람 리스트 + HashMap myList = new HashMap<>(); + //내가 받을 매일 횟수 + + for(int i=0;i()); + myList.put(id_list[i], 0); + } + + for(int i=0;i=k) { + + System.out.println(singoList.get(key)); + + for(String str : singoList.get(key)) { + + myList.put(str, myList.get(str)+1); + + + } + } + + } + + for(int i=0;i15) { + new_id = new_id.substring(0,15); + new_id = new_id.replaceAll("[.]$", ""); + } + + if(new_id.length()<3) { + while(new_id.length()<3) { + new_id += new_id.charAt(new_id.length()-1); + } + } + + System.out.println(new_id); + + } +} diff --git a/Basic_Of_Algorithm/src/programmers_level_01/no_3.java b/Basic_Of_Algorithm/src/programmers_level_01/no_3.java new file mode 100644 index 0000000..3b15d80 --- /dev/null +++ b/Basic_Of_Algorithm/src/programmers_level_01/no_3.java @@ -0,0 +1,22 @@ +package programmers_level_01; + +public class no_3 { + + public static void main(String[] args) { + + String s = "one4seveneight"; + int answer = 0; + + String [] alpha = {"zero","one","two","three","four","five","six","seven","eight","nine"}; + + + for(int i=0;i stack = new Stack<>(); + + for(int i=0;i fail_rate = new ArrayList<>(); + + int cnt = 0; + + for(int i=1;i<=n;i++) { + for(int j=0;jDouble.compare(b[1], a[1])); + + for(int i=0;i s.length() ? s.length() : i * (j+1); + + now = next; + next = s.substring(start,end); + + if(now.equals(next)) { + hit++; + }else { + result += processHit(hit) + now; + hit = 1; + } + + + + + } + + result += processHit(hit) + next; + + System.out.println(result); + + answer = Math.min(answer, result.length()); + } + + + System.out.println(answer); + + + + } + static String processHit(int hit) { + return hit > 1 ? String.valueOf(hit) : ""; + } + +} diff --git a/Basic_Of_Algorithm/src/programmers_level_2/no_2.java b/Basic_Of_Algorithm/src/programmers_level_2/no_2.java new file mode 100644 index 0000000..67169a0 --- /dev/null +++ b/Basic_Of_Algorithm/src/programmers_level_2/no_2.java @@ -0,0 +1,54 @@ +package programmers_level_2; + +import java.util.ArrayList; +import java.util.HashMap; + +public class no_2 { + + public static void main(String[] args) { + + String [] record = {"Enter uid1234 Muzi", "Enter uid4567 Prodo","Leave uid1234","Enter uid1234 Prodo","Change uid4567 Ryan"}; + + ArrayList answerList = new ArrayList<>(); + + HashMap map = new HashMap<>(); + + for(String str : record) { + + String[]temp = str.split(" "); + + String action = temp[0]; + if(action.equals("Leave")) continue; + String id = temp[1]; + String nick = temp[2]; + + map.put(id, nick); + + } + for(String str : record) { + + String[]temp = str.split(" "); + + String action = temp[0]; + if(action.equals("Change")) continue; + String id = temp[1]; + String nick = map.get(id); + + String ans = nick+"님이 " + (action.equals("Enter") ? "들어왔습니다." : "나갔습니다."); + + answerList.add(ans); + + + } + + String[]answer = new String[answerList.size()]; + + + for(int i=0;i2"}; + + + datas = data.clone(); + + boolean[]visited = new boolean[member.length]; + + dfs(visited,""); + + System.out.println(answer); + + } + static void dfs(boolean[]visited,String now) { + + if(now.length()==member.length) { + if(check(now)) answer++; + + return; + } + + + for(int i=0;i') { + if(!(Math.abs(pos1-pos2)>idx+1)) return false; + }else if(ch=='<') { + if(!(Math.abs(pos1-pos2) map = new HashMap<>(); + static ArrayList answerList = new ArrayList<>(); + + public static void main(String[] args) { + + String[] orders = {"ABCFG", "AC", "CDE", "ACDE", "BCFG", "ACDEH"}; + int [] course = {2,3,4}; + + for(int i=0;i list = new ArrayList<>(map.values()); + int max = Collections.max(list); + if(max>1) { + for(String key : map.keySet()) { + if(map.get(key)==max) { + answerList.add(key); + } + } + + } + + + + } + + + map.clear(); + } + + String[]answer = new String[answerList.size()]; + + Collections.sort(answerList); + + for(int i=0;i arr1 = new ArrayList<>(); + ArrayList arr2 = new ArrayList<>(); + + + + for(int i=0;i='a'&&first<='z')&&(second>='a'&&second<='z')) { + arr1.add(""+first+second); + } + } + + for(int i=0;i='a'&&first<='z')&&(second>='a'&&second<='z')) { + arr2.add(""+first+second); + } + } + double son = 0; + double mom = 0; + + mom = arr1.size() + arr2.size(); + + System.out.println(mom); + + for(int i=0;i numArr = new ArrayList<>(); + static ArrayList opArr = new ArrayList<>(); + static char[]op = {'+','-','*'}; + static long answer = Integer.MIN_VALUE; + static boolean[]visited = new boolean[3]; + + public static void main(String[] args) { + + String expression = "100-200*300-500+20"; + + change(expression); + + dfs(new char[3] ,0); + + System.out.println(answer); + + } + + static Long changeNum(char ch , long a, long b) { + + if(ch=='+') return a+b; + else if(ch=='*') return a*b; + else if(ch=='-') return a-b; + + return (long) 0; + } + + static void dfs(char[]p,int count) { + + if(count==3) { + + ArrayList numList = new ArrayList<>(numArr); + ArrayList opList = new ArrayList<>(opArr); + + for(int i=0;i='0'&&ch<='9') { + num += ch; + }else { + numArr.add(Long.parseLong(num)); + opArr.add(ch); + num = ""; + + } + + } + + numArr.add(Long.parseLong(num)); + + } +}