PS
-
boj)17413 - 단어 뒤집기 2PS/boj 2020. 9. 14. 17:51
import java.io.*; import java.util.Stack; public class boj_17413 { static Stack s = new Stack(); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringBuilder sb = new StringBuilder(); public static void main(String[] args) throws IOException { char[] chars = br.readLine().toCharArray(); boolean isTag = false; for (char aChar : chars) { if (aChar == '') { ..
-
boj)1158 - 요세푸스 문제PS/boj 2020. 9. 14. 16:38
import java.io.*; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; public class boj_1158 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken(..
-
boj)1406 - 에디터PS/boj 2020. 9. 14. 01:31
import java.io.*; import java.util.Stack; public class boj_1406 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); Stack left = new Stack(); Stack right = new Stack(); String first = br.readLine(); int m = Integer.parseInt(br.readLine())..
-
boj)1874 - 스택 수열PS/boj 2020. 9. 13. 23:41
import java.io.*; import java.util.Stack; public class boj_1874 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); Stack s = new Stack(); int n = Integer.parseInt(br.readLine()); // 1 ~ 100,000 int item = 0; // 스택에 오름차순으로 쌓일 수 while (n-- > 0) { int x = Integer.parseInt(br...
-
boj)9012 - 괄호PS/boj 2020. 9. 13. 19:15
import java.io.*; public class boj_9012 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int T = Integer.parseInt(br.readLine()); for (int i = 0; i < T; i++) { String str = br.readLine(); int temp = 0; for (int j = 0; j < str.length();..
-
boj)9093 - 단어 뒤집기PS/boj 2020. 9. 13. 19:12
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Stack; public class boj_9093 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuffer sb = new StringBuffer(); int T = Integer.parseInt(br.readLine()); for (int i = 0; i < T; i++) { String str = b..
-
boj)10828 - 스택구현PS/boj 2020. 9. 13. 19:10
import java.io.*; public class boj_10828 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); stack s = new stack(N); for (int i = 0; i < N; i++) { String str = br.readLine(); switch (str) { case "push" : s.push(Integer.parseInt(str.split(" ")[1])); case "pop" : s.pop(); ca..
-
Level1) x만큼 간격이 있는 n개의 숫자PS/programmers 2020. 9. 12. 03:25
class Solution { public long[] solution(int x, int n) { long[] answer = new long[n]; long temp = x; int index = 0; while (index != n) { answer[index] = temp; index++; temp += x; } return answer; } } - 성공 - for문보다 while 문 생각이 먼저나서 while문으로 풀었음 class Solution { public long[] solution(long x, int n) { long[] answer = new long[n]; for(int i = 0; i < n; i++){ answer[i] = x * (i + 1); } return answer;..