// 투포인터는 가변적 길이, 슬라이딩 윈도우는 고정적 길이import java.util.*;class Main { public int solution(int n, int m, int[] arr) { int answer = 0; int sum = 0; // 첫 3일치를 더하고 answer에 저장 for(int i = 0; i import java.util.*;class Main { public int solution(int n, int m, int[] arr) { int answer = 0; int sum = 0; for(int i = 0; i m; i++) { sum +=..
import java.util.*;class Main { public ArrayList solution(int n, int[] arr1, int m, int[] arr2) { ArrayList answer = new ArrayList(); int p1 = 0, p2 = 0; // 배열 오름차순 정렬 Arrays.sort(arr1); Arrays.sort(arr2); while(p1 import java.util.*;class Main { public ArrayListInteger> solution(int n, int[] arr1, int m, int[] arr2) { ArrayListIntege..
import java.util.*;class Main { public ArrayList solution(int n, int[] arr1, int m, int[] arr2) { ArrayList answer = new ArrayList(); int p1 = 0, p2 = 0; // n이 p1보다 크거나 m이 p2보다 크거나 && while(p1 import java.util.*;class Main { public ArrayListInteger> solution(int n, int[] arr1, int m, int[] arr2) { ArrayListInteger> answer = new ArrayList(); ..
import java.util.*;class Main { public int solution(int n, int m, int[][] arr){ int answer=0; for(int i=1; in; i++){ for(int j=1; jn; j++){ int cnt=0; for(int k=0; km; k++){ int pi=0, pj=0; for(int s=0; sn; s++){ if(arr[k][s]==i) pi=s; if(arr[k][s]==j)..
import java.util.*;class Main { public int solution(int n, int[][] arr) { int answer = 0; int max = 0; // i는 기준이 되는 학생 for(int i = 1; i max) { max = cnt; answer = i; } } } return answer; } public static void main(String[] args){ Main T = new Main(); Scanner kb = new Scanner(Syste..
import java.util.*;class Main { // 현재 위치를 기준으로 상, 하, 좌, 우 기준점 // dx = -1, dy = 0이면 상 // 대각선까지 고려하는 문제면 4개 더 추가 int[] dx = {-1, 0, 1, 0}; int[] dy = {0, 1, 0, -1}; public int solution(int n, int[][] arr) { int answer = 0; for(int i = 0; i = 0 && idx = 0 && idy = arr[i][j]) { // 1개라도 충족이 안되면 봉우리가 아니므로 break flag = false; ..
import java.util.*;class Main { public int solution(int n, int[][] arr) { // sum = 가로, 세로 int answer = 0, sum1 = 0, sum2 = 0; for(int i = 0; i import java.util.*;class Main { public int solution(int n, int[][] arr) { int answer = 0, sum1 = 0, sum2 = 0; for(int i = 0; i n; i++) { sum1 = sum2 = 0; for(int j = 0; j n; j++) { ..
i가 0일 때87 (j = 0) > 87(i = 0) [cnt 유지]89 (j = 1) > 87(i = 0) [cnt + 1 = 2]92 (j = 2) > 87(i = 0) [cnt + 1 = 3] 100 (j = 3) > 87(i = 0) [cnt + 1 = 4] 76 (j = 4) > 87(i = 0) [cnt 유지] import java.util.*;class Main { public int[] solution(int n, int[] arr) { int[] answer = new int[n]; for(int i = 0; i n; i++) { int cnt = 1; for(int j = 0; j n; j++) ..
import java.util.*;class Main { public int solution(int n, int[] arr) { int answer = 0; int cnt = 0; for(int i = 0; i import java.util.*;class Main { public int solution(int n, int[] arr) { int answer = 0; int cnt = 0; for(int i = 0; i n; i++) { if(arr[i] == 1) { cnt++; answer += cnt; } e..
import java.util.*;class Main { public boolean isPrime(int num) { // 1은 소수가 아님 if(num == 1) { return false; } // num % i가 0이면 소수가 아님 for(int i = 2; i solution(int n, int[] arr) { ArrayList answer = new ArrayList(); String[] str = new String[arr.length]; for(int i = 0; i string 형변환 str[i] = Integer.toString(arr[i]); ..