
Softeer - 8단 변속기
2023. 2. 17. 23:17
알고리즘(종합)/Lv.2
문제 분석 경우의 수 3가지에 대해서 출력한다 1->8 8->1 그 외 첫번째와 두번째 경우의 수를 체크하고 그렇지 않으면 예외인 경우를 출력했다. 오름차순일경우 1인지 체크 , 2인지 체크 ... 내림차순일경우 8인지 체크, 7인지 체크... 전체 소스 int compare_one =1; int compare_eight = 8; for(int i=0; i

프로그래머스 - 귤 고르기
2023. 2. 15. 20:41
알고리즘(종합)/Lv.2
문제 풀이 문제는 간단하다 가장 반복되는 수를 더 해주면서 결과값을 도출하면된다, 하지만 문제는 시간초과이다. 내림차순을 해야하는데 이방법이 쉽지가 않다. 필자의 블로그에 오신분들도 아마 이런문제 때문에 오셨다고 생각한다. 방법은 간단한 오름차순을 해서 역순으로 체크하면 된다. 아마 Arrays.sort는 다들 아신다고 생각한다. 여기서 가장 뒤에값부터 체크한다. (전체에서 Max값을 찾는방법, 2중 for으로 내림차순 정렬 다 해봤지만 시간초과가 뜬다.) 전체 소스 import java.util.*; import java.io.*; class Solution { public int solution(int k, int[] tangerine) throws Exception { int answer = 0; ..

2001 - 파리퇴치
2022. 11. 14. 17:14
알고리즘(종합)/Lv.2
package test; import java.io.IOException; import java.util.Scanner; public class Solution { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int test = sc.nextInt(); for (int k = 0; k < test; k++) { int s = sc.nextInt(); int p = sc.nextInt(); int count=0; int max=0; int[][] array = new int[s][s]; for (int i = 0; i < s; i++) { for (int j = 0; j < s;..

1204 - 최빈수 구하기
2022. 11. 14. 00:16
알고리즘(종합)/Lv.2
package test; import java.io.IOException; import java.util.Scanner; public class Solution { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int test= sc.nextInt(); for (int k = 0; k < test; k++) { int max=0; int ss=0; int a = sc.nextInt(); int[] array = new int[101]; for(int i=0;i

1954 - 달팽이 숫자
2022. 11. 13. 23:10
알고리즘(종합)/Lv.2
package test; import java.io.IOException; import java.util.Scanner; public class Solution { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int test= sc.nextInt(); for (int k = 0; k < test; k++) { int a = sc.nextInt(); int x = 0; int y = -1; int output = 1; int m = 1; int[][] array = new int[a][a]; while (output = 0; i--) { // m이 -1이 될예정 y--; arra..

1926 - 간단한 369 게임
2022. 11. 13. 00:26
알고리즘(종합)/Lv.2
package test; import java.util.Scanner; class Solution { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); String num = "sample"; String sub1; String sub2; String sub3; for (int i = 1; i

1859 - 백만 장자 프로젝트
2022. 11. 11. 01:08
알고리즘(종합)/Lv.2
class Solution { public static void main(String args[]) throws Exception { Scanner sc = new Scanner(System.in); int T; T=sc.nextInt(); for(int test_case = 1; test_case