Study(진행중)
-
99클럽 코테 스터디 20일차 TIL / 섬 연결하기(프로그래머스)Study(진행중)/항해99 2024. 8. 11. 02:44
오늘의 학습 키워드 - 알고리즘 - 최소 신장 트리(MST) - 그리디 알고리즘 - 프림 알고리즘 - 우선순위 큐공부한 내용 본인의 언어로 정리하기https://school.programmers.co.kr/learn/courses/30/lessons/42861최소 신장 트리(MST) 문제를 풀었다. MST 문제의 경우 크루스칼과 프림 알고리즘 중 1개를 이용해 풀 수 있고,개인적으로는 크루스칼 알고리즘이 좀 더 직관적이라 이를 이용해 풀었다. 크루스칼 일고리즘은 다음과 같다.1. 모든 정점에 대한 간선을 우선순위 큐에 넣는다2. 가장 짧은 간선이 나올 때 마다 포함된 두 정점이 하나라도 전체 그래프와 연결되지 않았다면,해당 정점을 방문 처리를 하고 그 간선의 길이를 더해준다. 풀이는 ..
-
99클럽 코테 스터디 19일차 TIL / 조이스틱(프로그래머스)Study(진행중)/항해99 2024. 8. 10. 04:08
오늘의 학습 키워드 - 알고리즘 - 구현 - 그리디공부한 내용 본인의 언어로 정리하기그리디 문제를 풀었는데, 그리디 문제는 분류를 알면 그리디하게 풀려고 노력하지만, 이를 실전 문제에서 적용하는건 무리가 있다고 생각된다. 풀이는 다음과 같다.class Solution { public int solution(String name) { int totalMove = 0; int curLoc = 0; int minMove = Integer.MAX_VALUE; char[] nameArr = name.toCharArray(); int size = nameArr.length; totalMove += Math.min('..
-
99클럽 코테 스터디 18일차 TIL / 일루미네이션(백준)Study(진행중)/항해99 2024. 8. 8. 20:17
오늘의 학습 키워드 - 알고리즘 - 구현 - BFS공부한 내용 본인의 언어로 정리하기https://www.acmicpc.net/problem/5547BFS를 응용하는 문제를 풀었다. 풀이 과정에서 가장 중요한 것은 현재 위치가 홀수번째인지, 짝수번째인지에 따라 근처 집이 어떤 좌표로 구성되는지 찾는 것 이었다. 풀이는 다음과 같다.import java.io.*;import java.lang.reflect.Array;import java.util.*;class Main { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static in..
-
99클럽 코테 스터디 17일차 TIL / 사자와 토끼(백준)Study(진행중)/항해99 2024. 8. 7. 20:34
오늘의 학습 키워드 - 알고리즘 - 그래프 탐색 - 이분 그래프공부한 내용 본인의 언어로 정리하기https://www.acmicpc.net/problem/17834그래프 탐색 문제를 풀었는데, 이분 그래프 개념이 들어가 있었다.해당 개념을 몰라 찾아보고 다시 풀게 되었다. 이분 그래프란 쉽게말해 한 정점과 연결된 그래프의 색상이 빨강이고 하면,빨간 정점과 연결된 모든 정점은 파랑색 정점이고, 파란 정점과 연결된 모든 정점은 빨간색 정점으로 이루어진 그래프이다. 그래서 예시로 주어진 그림을 표현하면 아래와 같이 이분 그래프가 성립한다. 하지만 3번 예시의 경우 아래와 같이 이분 그래프가 성립하지 않는다. 그래서 이분 그래프를 어떻게 이 문제에서 활용하냐면만약 이분그래프가 성립된다면 사자와 토끼가..
-
99클럽 코테 스터디 16일차 TIL / N-Queen(프로그래머스)Study(진행중)/항해99 2024. 8. 7. 02:17
오늘의 학습 키워드 - 알고리즘 - 완전 탐색 - 백트래킹공부한 내용 본인의 언어로 정리하기https://school.programmers.co.kr/learn/courses/30/lessons/12952백트래킹을 이용한 완전탐색 문제를 풀었다.공격 가능한지 판단하는 로직이 따로 있을 것 같아 종이에 적어가며 규칙을 찾았고,이후에는 무식하기 현재 위치로부터 위에 놓은 체스말들을 보며 놓을 수 있는지를 판단했다. 풀이 과정은 다음과 같다.1. 현재 y축으로부터 위에 모든 체스말들을 보며 x축에 놓을 수 있는지 판단2. 이후 백트래킹 로직을 수행하며 깊이가 n이 될 때 까지 실행 풀이는 다음과 같다.class Solution { int n, cnt = 0; int[] board;..
-
99클럽 코테 스터디 15일차 TIL / 소수 찾기(프로그래머스)Study(진행중)/항해99 2024. 8. 6. 01:16
오늘의 학습 키워드 - 알고리즘 - 완전 탐색 - 소수 판별(에라토스테네스의 체) - 백트래킹공부한 내용 본인의 언어로 정리하기https://school.programmers.co.kr/learn/courses/30/lessons/42839소수 판별 알고리즘과 백트래킹을 이용해야 하는 문제를 풀었다.에라토스테네스의 체 알고리즘은 처음 들었을 때는 모르면 당해야지 싶었지만, 다행히 기억이 나서 쉽게 풀었다. 풀이 과정은 다음과 같다.1. 전체 숫자가 몇 개인지 size 변수에 저장2. 에라토스테네스의 체 알고리즘 사용을 위해 10^size 만큼의 boolean[] 배열을 선언2 - 1. 에라토스테네스의 체는 2부터 n까지 반복문을 돌며 만약 현재 숫자가 방문 처리가 안되었을 경우 소수이고,현..
-
99클럽 코테 스터디 14일차 TIL / 운영체제 - 프로세스Study(진행중)/항해99 2024. 8. 5. 01:23
오늘의 학습 키워드 - 운영체제공부한 내용 본인의 언어로 정리하기Process? → 실행중인 프로그램(program in execution)program that performs a single thread of execution 단일의 실행 스레드를 실행하는 프로그램 OS 입장에서는 작업에서 단위가 프로세스 단위하나의 프로세스가 실행하기 위해서는 자원(Resource)이 필요CPUMemoryFile, IO Device등프로세스들의 메모리 배치 섹션Text → 실행 코드Data → 전역 변수Heap → 프로그램 실행 중에 동적으로 할당되는 메모리(new, malloc)Stack → 함수를 호출할 때 임시 데이터 저장장소(매개변수, 복귀 주소, 지역 변수)프로세스를 제어하는 방법?PCB(Process..
-
99클럽 코테 스터디 13일차 TIL + 입국심사(프로그래머스)Study(진행중)/항해99 2024. 8. 4. 03:44
오늘의 학습 키워드 - 알고리즘 - 이분탐색공부한 내용 본인의 언어로 정리하기https://school.programmers.co.kr/learn/courses/30/lessons/43238이분 탐색을 활용하는 문제를 풀었다.이분탐색은 문제가 이분탐색 문제인지 알아보는 것과while 문 안에 조건을 잘 설정해줘야 풀 수 있는 것 같다. 풀이 과정은 다음과 같다.1. 이분탐색의 범위는 0 ~ 최대값2. 탐색의 범위를 좁혀가며 심사관이 n명 이상 사람을 평가할 수 있다면 범위를 줄여야 하므로 right = mid - 1로아니라면 범위를 늘려야 하므로 left = mid + 1로 설정한다. 풀이는 다음과 같다.class Solution { public long solution(int n, ..