백준_11003 최솟값 찾기 (슬라이딩 윈도우)
Algorithm/Algorithm 문제2023. 11. 29. 23:18백준_11003 최솟값 찾기 (슬라이딩 윈도우)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Deque; import java.util.LinkedList; import java.util.StringTokenizer; public class BJ_11003 { static class Node { long ind; long val; Node(long ind, long val) { this.ind = ind; this.val = val; } } public static void main(String[] args) throws IOException { BufferedReader br = new Buffere..

백준_12891 DNA 비밀번호 (슬라이딩 윈도우)
Algorithm/Algorithm 문제2023. 11. 24. 22:27백준_12891 DNA 비밀번호 (슬라이딩 윈도우)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_12891 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine(), " "); int i, j; int s = Integer.parseInt(st.nextToken());..

백준_1253 좋다 (투포인터)
Algorithm/Algorithm 문제2023. 11. 23. 12:43백준_1253 좋다 (투포인터)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class BJ_1253 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); long[] arr = new long[n]; int i; StringTokenizer..

백준_1940 주몽 (투포인터)
Algorithm/Algorithm 문제2023. 11. 23. 11:59백준_1940 주몽 (투포인터)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class BJ_1940 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int m = Integer.parseInt(br.readLine()); int res..

백준_2018 수들의 합 5 (투포인터)
Algorithm/Algorithm 문제2023. 11. 22. 11:14백준_2018 수들의 합 5 (투포인터)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BJ_2018 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int start_pointer = 1; int end_pointer = 1; int sum = 1; int cnt = 1; while(end_pointer!=n){ if(n > sum) { ..

백준_10986 나머지 합 (구간합배열)
Algorithm/Algorithm 문제2023. 11. 21. 22:58백준_10986 나머지 합 (구간합배열)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_10986 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine(), " "); int i, temp; long result = 0; int n = Integer.parse..

백준_11660 구간 합 구하기 5 (구간합배열)
Algorithm/Algorithm 문제2023. 11. 20. 23:10백준_11660 구간 합 구하기 5 (구간합배열)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_11660 { 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 = Int..

백준_11659 구간 합 구하기 4 (구간합배열)
Algorithm/Algorithm 문제2023. 11. 18. 19:51백준_11659 구간 합 구하기 4 (구간합배열)

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class BJ_11659 { public static void main(String[] args) throws IOException { int i, j, t; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; StringBuilder sb = new StringBuilder(); st = new StringTokenizer(br.readLine(), ..

구간 합 배열
Algorithm/자료구조&알고리즘2023. 11. 18. 19:51구간 합 배열

구간 합 배열 이용 시 시간 복잡도를 O(n)에서 O(1)로 개선

image