본문 바로가기

반응형

Java

(376)
[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.공통원소 구하기 두 개의 집합에서 공통 원소를 추출하여 오름차순으..
[Java 알고리즘] 2. Array 모음 https://cote.inflearn.com/contest/10/problem/02-01 OnlineJudge cote.inflearn.com https://and-some.tistory.com/529 [Ch.02 - Array] 01. 큰 수 출력하기 1. 큰 수 출력하기 설명 N개의 정수를 입력받아, 자신의 바로 앞 수보다 큰 수만 출력하는 프로그램을 작성하세요. (첫 번째 수는 무조건 출력한다) 입력 첫 줄에 자연수 N(1 and-some.tistory.com https://cote.inflearn.com/contest/10/problem/02-02 https://and-some.tistory.com/530 [Ch.02 - Array] 02. 보이는 학생 2. 보이는 학생 설명 선생님이 N명의 학..
[Java 알고리즘] 1. String 모음 https://cote.inflearn.com/contest/10/problem/01-01 https://and-some.tistory.com/517 [Ch.01 - String] 01. 문자 찾기 (+ toCharArray) 1. 문자 찾기 설명 한 개의 문자열을 입력받고, 특정 문자를 입력받아 해당 특정문자가 입력받은 문자열에 몇 개 존재하는지 알아내는 프로그램을 작성하세요. 대소문자를 구분하지 않습니다.문 and-some.tistory.com https://cote.inflearn.com/contest/10/problem/01-02 https://and-some.tistory.com/518 [Ch.01 - String] 02. 대소문자 변환 (+ toCharArray) 2. 대소문자 변환 설명 대문..
[LeetCode- Part. 4] 5. 이진 매트릭스 최단경로 (+BFS) https://leetcode.com/problems/shortest-path-in-binary-matrix/ Shortest Path in Binary Matrix - 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. 예외처리 (1) 갈 수 없는 경우 (2) 시작점 또는 도착점이 1인 경우 (3) 시작점이 도착점인 경우 2. BFS를 돌면서 도착점이면 리턴 class Solution { public int shortestPathBinaryMatrix(int[..
[LeetCode- Part. 4] 4. 최대 정사각형 # (+ 2차원 DP) https://leetcode.com/problems/maximal-square/ Maximal Square - 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 규칙을 찾아서 DP 배열을 작성한다. class Solution { public int maximalSquare(char[][] matrix) { //1. ds int m = matrix.length; int n=matrix[0].length; //DP에서 필요한 길이만큼 배열 생성 int[][] dp =..
[LeetCode- Part. 4] 3. 작업 일정의 최소 난이도 # (+ 2차원 DP) https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule/ Minimum Difficulty of a Job Schedule - 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 jobDifficulty ={6,5,4,3,2,1}, d=2 jobDifficulty ={7,1,7,1,7,1}, d=3 문제 분석 날짜들의 최솟값을 구하기 위해서는 각각의 날짜의 최곳값을 더해야한다. -> DP로 구현 가능한 ..
[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. K값에 해당하는 윈도우 초기값 설정 2. 한칸씩 제거하고 추가하는 작업 수행 3. 타임리밋 발생 +) 스트림을 이용한 최댓값 구하기 //스트림을 int형으로 매핑 후, 최댓값 찾아서 스트림을 다시 int형으로 변환 Integer maxValue =li..
[LeetCode- Part. 4] 1. N일 후 감옥 ## (+ 재귀함수, Arrays.toString, 삼항연산자) https://leetcode.com/problems/prison-cells-after-n-days/submissions/ Prison Cells After N Days - 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. 2중 for문 -> 타임리밋 발생 2. 재귀 이용 class Solution { public int[] prisonAfterNDays(int[] cells, int n) { //감옥이 사용될경우 1, 비어있을 경우 0 //양쪽의 감옥이 모두..

반응형