From ba4ddf51c0c3421f3937f886a409afd96fb439bf Mon Sep 17 00:00:00 2001 From: monsileI Date: Wed, 8 Jun 2022 21:59:27 +0900 Subject: [PATCH] =?UTF-8?q?BFS,=20=EB=AC=B8=EC=9E=90=EC=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Today_22_06_08/gameMapQueue.java | 52 +++++++++++++ .../src/Today_22_06_08/menuRenewal.java | 73 +++++++++++++++++++ .../src/Today_22_06_08/stringApchuck.java | 56 ++++++++++++++ 3 files changed, 181 insertions(+) create mode 100644 Basic_Of_Algorithm/src/Today_22_06_08/gameMapQueue.java create mode 100644 Basic_Of_Algorithm/src/Today_22_06_08/menuRenewal.java create mode 100644 Basic_Of_Algorithm/src/Today_22_06_08/stringApchuck.java diff --git a/Basic_Of_Algorithm/src/Today_22_06_08/gameMapQueue.java b/Basic_Of_Algorithm/src/Today_22_06_08/gameMapQueue.java new file mode 100644 index 0000000..e9993bc --- /dev/null +++ b/Basic_Of_Algorithm/src/Today_22_06_08/gameMapQueue.java @@ -0,0 +1,52 @@ +package Today_22_06_08; + +import java.util.Queue; +import java.util.LinkedList; + +public class gameMapQueue { + + public static void main(String[] args) { + + int[][]maps = {{1,0,1,1,1},{1,0,1,0,1},{1,0,1,1,1},{1,1,1,0,1},{0,0,0,0,1}}; + + int[][]move = {{0,1},{1,0},{0,-1},{-1,0}}; + + int answer = 0; + + int[][]temp = new int[maps.length][maps.length]; + + temp[0][0] = 1; + + Queue q = new LinkedList<>(); + + q.add(new int[] {0,0}); + + while(!q.isEmpty()) { + + int[]cur = q.poll(); + + int i = cur[0]; + int j = cur[1]; + + for(int d=0;d<4;d++) { + + int newI = move[d][0] + i; + int newJ = move[d][1] + j; + + if(newI<0||newJ<0||maps.length-1 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 maxList = new ArrayList<>(map.values()); + int max = Collections.max(maxList); + 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 " +result.length()); + + + } + + if(answer==Integer.MAX_VALUE) answer=1; + + System.out.println(answer); + + + + } + static String hitProess(int hit) { + return hit>1 ? String.valueOf(hit) : ""; + } +}