package problem_solving.stack;
import java.util.Scanner;
import java.util.Stack;
public class BaekJoon_1874 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.next());
Stack<Integer> st = new Stack();
int start = 0 ;
StringBuilder sb = new StringBuilder();
while(n-- > 0) {
int num = Integer.parseInt(sc.next());
if( num > start ) {
for(int i= start+1 ; i<= num ; i++) {
st.push(i);
sb.append("+"+'\n');
}
start = num ;
}
if( st.peek() != num ) {
System.out.println("NO");
return ;
}else {
st.pop();
sb.append("-"+'\n');
}
}
System.out.println(sb);
}
}
package problem_solving.stack;
import java.util.Scanner;
import java.util.Stack;
public class BaekJoon_10773 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.next());
Stack<Integer> st = new Stack();
long sum = 0 ;
for(int i= 0 ; i < n ; i++) {
int num = Integer.parseInt(sc.next());
if( num !=0 ) {
st.push(num);
}else {
st.pop();
}
}
while(!st.isEmpty()) {
sum+=st.pop();
}
System.out.println(sum);
}
}
package problem_solving.stack;
import java.util.Arrays;
import java.util.Scanner;
public class BaekJoon_12605 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.next());
sc.nextLine();
for(int i = 0 ; i < n; i ++) {
StringBuilder sb= new StringBuilder("Case #"+(i+1)+": ");
String s = sc.nextLine();
String[] arr = s.split(" ");
for(int j = arr.length-1 ; j >= 0 ; j--) {
sb.append(arr[j]+ " ");
}
System.out.println(sb.toString());
}
}
}
package problem_solving.stack;
import java.util.Scanner;
import java.util.Stack;
public class BaekJoon_17608 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.next());
Stack<Integer> st = new Stack();
for(int i= 0 ; i < n ; i++) {
int num = Integer.parseInt(sc.next());
st.push(num);
}
int cnt = 0 ;
int last = st.pop();
int temp = last ;
int i= 0 ;
while(!st.isEmpty()) {
if(st.peek() > last && st.peek() > temp) {
temp = st.peek();
st.pop();
cnt++;
}else {
st.pop();
}
}
System.out.println(cnt+1);
}
}
package problem_solving.hash;
import java.util.HashSet;
import java.util.Scanner;
public class BaekJoon_9933 {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int n = Integer.parseInt(sc.next());
HashSet<String> hs = new HashSet();
int size = hs.size();
for(int i= 0 ; i < n ; i++) {
StringBuilder sb = new StringBuilder(sc.next());
if( sb.toString().equals(sb.reverse().toString())) {
System.out.print(sb.length()+" "+sb.charAt(sb.length()/2));
return ;
}
hs.add(sb.toString());
hs.add(sb.reverse().toString());
if( size == hs.size()) {
System.out.print(sb.length()+" "+sb.charAt(sb.length()/2));
return ;
}else {
size = hs.size();
}
}
}
}
https://incredibox-game.io/home 는 쉽고 재미있는 방식으로 음악을 만드는 능력에 놀랐습니다. 다양한 비트박스 사운드를 조합해 리드미컬한 멜로디를 만들어내는 것은 정말 자극적이다. 게임의 각 버전은 독특한 것을 제공하며, 저는 음악적 창의성의 무한한 가능성에 매료되었습니다. 간단한 드래그 앤 드롭 방식으로 게임에 접근하기가 쉽지만, 그것이 제공하는 음악적 창의성은 놀랍습니다.
멋져용~