본문 바로가기

Java/Java 알고리즘 모음

[Java 알고리즘] 3. 투포인터/슬라이딩윈도우/연속부분수열 모음

반응형

https://cote.inflearn.com/contest/10/problem/03-01

https://and-some.tistory.com/511

 

[Ch.03 - 투 포인터] 1. 두 배열 합치기

1. 두 배열 합치기 설명 오름차순으로 정렬이 된 두 배열이 주어지면 두 배열을 오름차순으로 합쳐 출력하는 프로그램을 작성하세요. 입력 첫 번째 줄에 첫 번째 배열의 크기 N(1

and-some.tistory.com

 

 

https://cote.inflearn.com/contest/10/problem/03-02

https://and-some.tistory.com/512

 

[Ch.03 - 투 포인터] 2. 공통원소 구하기 (+하나씩 확인하는 방법)

2.공통원소 구하기 두 개의 집합에서 공통 원소를 추출하여 오름차순으로 출력 입력값 5 1 3 9 5 2 5 3 2 5 7 8 출력값 2 3 5 import java.util.*; public class Main { public ArrayList solution(int[] arr1, int[] arr2){ ArrayList

and-some.tistory.com

 

https://cote.inflearn.com/contest/10/problem/03-03

https://and-some.tistory.com/513

 

[Ch.03 - 투 포인터] 3. 최대 매출 (+ 슬라이딩 윈도우)

3.최대 매출 N일 동안 매출기록 중 연속 k일 동안 최대 매출액 구하기 입력값 10 3 12 15 11 20 25 10 20 19 13 15 출력값 56 package twopointer.ch03; import java.util.Scanner; //최대 매출 //총 n일 중, 연속 k일간의 최대

and-some.tistory.com

 

https://cote.inflearn.com/contest/10/problem/03-04

https://and-some.tistory.com/514

 

[Ch.03 - 투 포인터] 4. 연속 부분수열

4. 연속 부분수열 연속 부분수열 N개에서 합이 자연수 M이 되는 경우 횟수 구하기 입력값 8 6 1 2 1 3 1 1 1 2 출력값 3 (1) 1. while (p1 < n) 합계에 p1이 가리키는 값을 더한다. 2. while (p2 < n&&sum 맨 앞의 값

and-some.tistory.com

 

https://cote.inflearn.com/contest/10/problem/03-05

https://and-some.tistory.com/515

 

[Ch.03 - 투 포인터] 5. 연속된 자연수의 합 #

5. 연속된 자연수의 합 양의 정수 N을 2개 이상의 연속된 자연수 합으로 표현하는 가짓수 출력 입력값 15 출력값 3 package twopointer.ch03; import java.util.Scanner; //연속된 자연수의 합 //자연수 N을 2개 이

and-some.tistory.com

 

 

https://cote.inflearn.com/contest/10/problem/03-06

https://and-some.tistory.com/516

 

[Ch.03 - 투 포인터] 6. 최대 길이 연속부분수열 #

6. 최대 길이 연속 부분수열 0과 1로 구성된 길이가 N인 수열에서, 최대 k번 변경가능한데, 0을 1로 변경가능 최대 k번의 변경을 통해 1로만 구성된 최대 길이의 연속부분수열 출력 입력값 14, 2 1 1 0

and-some.tistory.com

 


 

https://leetcode.com/problems/longest-substring-without-repeating-characters/submissions/

 

Longest Substring Without Repeating Characters - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

https://and-some.tistory.com/901

 

[LeetCode- Ch4. 투 포인터] 1. 단어중복없는 가장 긴 문자열 #(+ 슬라이딩 윈도우)

https://leetcode.com/problems/longest-substring-without-repeating-characters/submissions/ Longest Substring Without Repeating Characters - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get

and-some.tistory.com

 

 

https://www.lintcode.com/problem/928/description

 

LintCode 炼码

 

www.lintcode.com

https://and-some.tistory.com/902

 

[LeetCode- Ch4. 투 포인터] 2. 최대 2개의 고유 문자가있는 가장 긴 부분 문자열 #

https://www.lintcode.com/problem/928/description LintCode 炼码 www.lintcode.com 1. rt를 이용해 문자열 길이까지 ++하면서 돈다. 2. 2개 이상인 개수 체크 3. 2개 이상인 문자를 없앤다. -> put으로 개수를 -1씩 하고, 0개

and-some.tistory.com

 

 

https://leetcode.com/problems/find-all-anagrams-in-a-string/

 

Find All Anagrams in a String - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

https://and-some.tistory.com/903

 

[LeetCode- Ch4. 투 포인터] 3. 문자열에서 모든 아나그램 찾기

https://leetcode.com/problems/find-all-anagrams-in-a-string/ Find All Anagrams in a String - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com

and-some.tistory.com

 

 

 


https://leetcode.com/problems/sliding-window-maximum/submissions/

 

Sliding Window Maximum - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

https://and-some.tistory.com/949

 

[LeetCode- Part. 4] 2. 슬라이딩 윈도우 최댓값 #(+슬라이딩 윈도우, Deque)

https://leetcode.com/problems/sliding-window-maximum/submissions/ Sliding Window Maximum - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1

and-some.tistory.com

 

 

https://and-some.tistory.com/941

 

2. 카드 점수 (+슬라이딩 윈도우)

DFS 이용한 풀이 package Q2; import java.util.Arrays; public class Main { //카드 점수 //카드 종류와 뽑을 카드 수가 주어지면 //가장 왼쪽 또는 가장 오른쪽 끝에 있는 카드를 가져온다. //가져온 카드의 총 합

and-some.tistory.com

 

반응형