From addf9e4e697744de60f2f8af5554c733bc295271 Mon Sep 17 00:00:00 2001 From: sujunghwang <64738942+sujunghwang@users.noreply.github.com> Date: Thu, 23 Feb 2023 09:45:08 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Week05=20PRG=2042584=20=EC=A3=BC=EC=8B=9D?= =?UTF-8?q?=EA=B0=80=EA=B2=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sujunghwang/week05/PRG_42584.java | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 sujunghwang/week05/PRG_42584.java diff --git a/sujunghwang/week05/PRG_42584.java b/sujunghwang/week05/PRG_42584.java new file mode 100644 index 0000000..6592743 --- /dev/null +++ b/sujunghwang/week05/PRG_42584.java @@ -0,0 +1,27 @@ +/* +https://school.programmers.co.kr/learn/courses/30/lessons/42584?language=java + +주어진 배열을 탐색하면서 현재 값보다 작은 값이 언제 나오는지 구하면 되는 문제 +문제 카테고리는 스택/큐 였는데 모르겠어서 그냥 배열로 이중 for loop 돌림 +효율성 문제 생길 줄 알았는데 안생겨서 그냥 넘어가기로 함 +*/ + +class Solution { + public int[] solution(int[] prices) { + int len = prices.length; + int[] answer = new int[len]; + + for(int i = 0; i < len-1; i++){ + answer[i] = 1; + for(int j = i+1; j < len-1; j++){ + if(prices[j] >= prices[i]){ + answer[i] += 1; + } else { + break; + } + } + } + + return answer; + } +} From 03076d23fd3da5630006d2d4a78f9a3d9a97544e Mon Sep 17 00:00:00 2001 From: sujung Date: Sat, 25 Feb 2023 23:04:54 +0900 Subject: [PATCH 2/3] remove --- sujunghwang/week05/PRG_42584.java | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 sujunghwang/week05/PRG_42584.java diff --git a/sujunghwang/week05/PRG_42584.java b/sujunghwang/week05/PRG_42584.java deleted file mode 100644 index 6592743..0000000 --- a/sujunghwang/week05/PRG_42584.java +++ /dev/null @@ -1,27 +0,0 @@ -/* -https://school.programmers.co.kr/learn/courses/30/lessons/42584?language=java - -주어진 배열을 탐색하면서 현재 값보다 작은 값이 언제 나오는지 구하면 되는 문제 -문제 카테고리는 스택/큐 였는데 모르겠어서 그냥 배열로 이중 for loop 돌림 -효율성 문제 생길 줄 알았는데 안생겨서 그냥 넘어가기로 함 -*/ - -class Solution { - public int[] solution(int[] prices) { - int len = prices.length; - int[] answer = new int[len]; - - for(int i = 0; i < len-1; i++){ - answer[i] = 1; - for(int j = i+1; j < len-1; j++){ - if(prices[j] >= prices[i]){ - answer[i] += 1; - } else { - break; - } - } - } - - return answer; - } -} From 352ab7c3c07d557ddb8bd7c897ac08375ecae00f Mon Sep 17 00:00:00 2001 From: sujunghwang <64738942+sujunghwang@users.noreply.github.com> Date: Wed, 1 Mar 2023 23:39:50 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Week06=20SWEA=201230=20=EC=95=94=ED=98=B8?= =?UTF-8?q?=EB=AC=B83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sujunghwang/week05/SWEA_1230.java | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 sujunghwang/week05/SWEA_1230.java diff --git a/sujunghwang/week05/SWEA_1230.java b/sujunghwang/week05/SWEA_1230.java new file mode 100644 index 0000000..429a6ed --- /dev/null +++ b/sujunghwang/week05/SWEA_1230.java @@ -0,0 +1,60 @@ +/* +명령어에 따라 주어진 암호문을 편집하는 문제 +리스트로 변환해서 암호문 편집을 편하게 할 수 있게 함 +*/ +import java.io.*; +import java.util.*; + +public class SWEA_1230 { + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + for (int tc = 1; tc <= 10; tc++) { + int N = Integer.parseInt(br.readLine()); + String org = br.readLine(); + int cnt = Integer.parseInt(br.readLine()); + String chg = br.readLine(); + List listOrg = new ArrayList<>(); + listOrg.addAll(Arrays.asList(org.split(" "))); + List listChg = new ArrayList<>(); + listChg.addAll(Arrays.asList(chg.split(" "))); + List temp = new ArrayList<>(); + + for (int i = 0; i < cnt; i++) { + if(listChg.get(0).equals("I")){ + int x = Integer.parseInt(listChg.get(1)); + int y = Integer.parseInt(listChg.get(2)); + for (int j = 0; j < y; j++) { + listOrg.add(x+j,listChg.get(j+3)); + } + for (int j = 0; j < 3+y; j++) { + listChg.remove(0); + } + } else if(listChg.get(0).equals("D")){ + int x = Integer.parseInt(listChg.get(1)); + int y = Integer.parseInt(listChg.get(2)); + + for (int j = 0; j < 3; j++) { + listChg.remove(0); + } + for (int j = 0; j < y; j++) { + listOrg.remove(x); + } + } else if(listChg.get(0).equals("A")){ + int y = Integer.parseInt(listChg.get(1)); + for (int j = 0; j < y; j++) { + listOrg.add(listChg.get(j + 2)); + } + for (int j = 0; j < 2+y; j++) { + listChg.remove(0); + } + } + } + System.out.println("#"+tc+" "); + for (int i = 0; i < 10; i++) { + System.out.print(listOrg.get(i)+" "); + } + System.out.println(); + } + + } +}