본문 바로가기

Language/Algorithm28

Increasing Sequence Counter Example Input : 8 130 135 148 140 145 150 150 153 Output : 5 My answer : import java.util.Scanner; class IncreasingSequenceCounter { public static void main(String[] args) { IncreasingSequenceCounter t = new IncreasingSequenceCounter(); Scanner kb = new Scanner(System.in); int a = kb.nextInt(); int[] b = new int[a]; for(int i = 0; i < a; i++) { b[i] = kb.nextInt(); } System.out.println(t.solutio.. 2023. 12. 5.
The elements that are greater than their predecessors Example Input : 6 7 3 9 5 6 12 Output : 7 9 6 12 My answer : import java.util.*; class NumberProcessor { public static void main(String[] args) { NumberProcessor t = new NumberProcessor(); Scanner kb = new Scanner(System.in); /* int cnt = kb.nextInt(); kb.nextLine(); String s = kb.nextLine(); for(int i : t.solution(cnt, s)) { System.out.print(i + " "); } */ int cnt = kb.nextInt(); int[] i = new .. 2023. 12. 4.
Cryptogram Example Input : 4 #****###**#####**#####**##** Output : COOL My answer : import java.util.Scanner; class BinaryConverter { public static void main(String[] args) { BinaryConverter t = new BinaryConverter(); Scanner kb = new Scanner(System.in); int a = kb.nextInt(); String s = kb.next(); System.out.println(t.solution(a,s)); } String solution(int a, String s) { String answer = ""; String stringToD.. 2023. 12. 2.
String Compression Example Input : KKHSSSSSSSE Output : K2HS7E My answer : import java.util.Scanner; class StringCompression { public static void main(String[] args) { StringCompression t = new StringCompression(); Scanner kb = new Scanner(System.in); String s = kb.next(); System.out.println(t.solution(s)); } String solution(String s) { String answer = ""; char[] ca = s.toCharArray(); int cnt = 1; answer += ca[0];.. 2023. 12. 2.