
🚀 풀이 후기이 문제를 풀다 보니 그래프에 순환이 있는지 파악하는 방법을 배우게 됐습니다.선행 조건이 없는 노드들을 모두 제거한 후, 제거하지 못한 노드들이 있다면 순환 그래프입니다.🌒 문제 설명선행수업을 들어야 다음 수업을 들을 수 있습니다.한 학기에는 여러 수업을 수강할 수 있습니다.수업을 다 들을 수 있는 최소 학기 수를 반환하는 문제입니다.만약 수업을 모두 들을 수 없다면 -1을 반환합니다.You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given an array relations where relations[i] = [prevCoursei, nextCours..

🚀 풀이 후기DP.. 너무 어렵습니다.string에서 index와 size가 1이 차이나다 보니 더 헷갈립니다. 🌒 문제 설명주어진 sentence 문자열 배열이 rows * cols 의 스크린에 몇 번 채워질 수 있는지 반환하는 문제입니다.문자열 배열의 순서는 바꿀 수 없고, 각 문자는 2줄로 쪼개져서도 안됩니다.같은 줄에서 각각의 문자는 구분되어야 합니다.Given a rows x cols screen and a sentence represented as a list of strings, return the number of times the given sentence can be fitted on the screen.The order of words in the sentence must rema..

🚀 풀이 후기StringTokenizer 까먹어서 다시 공부했습니다..BufferedReader에서 띄어쓰기로 구분된 값을 각 변수 혹은 배열에 저장하기 위해서는 StringTokenizer를 사용해야 합니다.하지만, 저장할 배열의 자료형이 String이거나 Character라면 더 간단한 방법을 사용할 수 있습니다.char charInput[] = br.readLine().toCharArray();String stringInput[] = br.readLine().split(" ");🌒 문제 설명🌓 문제 풀이티셔츠는 남아도 되지만 부족해서는 안되므로 (사이즈를 선택한 사람 수 / 티셔츠 묶음 수)를 했을 때 나머지가 있다면 한 묶음 더 주문해야 합니다.펜은 정확히 참가자 수만큼 준비되어야 하므로 (..

🚀 풀이 후기Leaf 노드만 찾아서 삭제하는 부분이 까다로웠습니다.Leaf 노드를 삭제하니 부모 노드도 Leaf 노드라고 착각하게 되는 것을 주의하면서 코드를 짜야합니다.🌒 문제 설명Given the root of a binary tree, collect a tree's nodes as if you were doing this:Collect all the leaf nodes.Remove all the leaf nodes.Repeat until the tree is empty. Example 1:Input: root = [1,2,3,4,5]Output: [[4,5,3],[2],[1]]Explanation:[[3,5,4],[2],[1]] and [[3,4,5],[2],[1]] are also consid..

🚀 풀이 후기자바 String 자료형에 특수문자를 쓸 때는 특정 특수문자는 "역슬래쉬" 를 앞에 넣어주면 됩니다.String 특수문자 표현의미\t탭\n줄 바꿈\'작은 따옴표(')\"큰 따옴표(")\\역슬래쉬(\)~!@#$%^&*{}[]()기타 특수문자🌒 문제 설명🌓 문제 풀이public class Main { public static void main(String[] args){ print(" ,r\'\"7"); print("r`-_ ,\' ,/"); print(" \\. \". L_r'"); print(" `~\\/"); print(" |"); print(" |"); ..

🚀 풀이 후기이진 탐색 문제를 오랜만에 푸니까 요령이 생겼습니다.항상 헷갈렸던 부분이 else if 구문에서 어느 조건에 answer 답변을 세팅해줘야 하는지였습니다.아래 문제에서 Example 2를 보면 nums[i] 일 때 answer = i+1 을 넣어주므로, 코드를 짤 때, target nums[i] 인 조건에서 answer = i 를 세팅해주면 됩니다. 🌒 문제 설명Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You must..

🚀 풀이 후기자바에서 String의 특정 index 에 있는 문자를 가져올 때 쓰는 함수는 `string.charAt(index)` 입니다.🌒 문제 설명🌓 문제 풀이import java.io.IOException;import java.io.BufferedReader;import java.io.InputStreamReader;public class Main{ public static void main(String[] args) throws IOException{ BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); String input = br.readLine(); ..

🚀 풀이 후기반환해야 하는 수 k를 "제거한 수의 개수" 로 잘못 해석했습니다.k = "제거하고 남은 수의 개수" 입니다.🌒 문제 설명Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The order of the elements may be changed. Then return the number of elements in nums which are not equal to val.Consider the number of elements in nums which are not equal to val be k, to get accepted, you need to do the foll..