목록전체 글
Step-by-Step
https://leetcode.com/problems/kth-largest-element-in-a-stream/ Kth Largest Element in a Stream - LeetCode Can you solve this real interview question? Kth Largest Element in a Stream - Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. Implement KthLargest class: leetcode.com HashMap으로 빈도 count 값 저..
https://leetcode.com/problems/kth-largest-element-in-a-stream/ Kth Largest Element in a Stream - LeetCode Can you solve this real interview question? Kth Largest Element in a Stream - Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. Implement KthLargest class: leetcode.com 1차원적 접근과 PQ이용은 상당히 차이난..

https://leetcode.com/problems/count-ways-to-build-good-strings/ Count Ways To Build Good Strings - LeetCode Can you solve this real interview question? Count Ways To Build Good Strings - Given the integers zero, one, low, and high, we can construct a string by starting with an empty string, and then at each step perform either of the following: * Append the char leetcode.com 100 solved 달성! 백준, 프..
https://leetcode.com/problems/uncrossed-lines/ Uncrossed Lines - LeetCode Can you solve this real interview question? Uncrossed Lines - You are given two integer arrays nums1 and nums2. We write the integers of nums1 and nums2 (in the order they are given) on two separate horizontal lines. We may draw connecting lines: a straigh leetcode.com 내 코드 설계의 문제점을 한 번 더 되짚어준 문제 연결된 모든 선을 인덱스 기준으로 정렬해서 DP..
https://leetcode.com/problems/spiral-matrix-ii/description/ Spiral Matrix II - LeetCode Can you solve this real interview question? Spiral Matrix II - Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order. Example 1: [https://assets.leetcode.com/uploads/2020/11/13/spiraln.jpg] Input: n = 3 O leetcode.com 흔한 시뮬레이션 문제 체감 난이도는 Easy같다. for 문으로 일일이 지정해..
https://www.acmicpc.net/problem/14567 14567번: 선수과목 (Prerequisite) 3개의 과목이 있고, 2번 과목을 이수하기 위해서는 1번 과목을 이수해야 하고, 3번 과목을 이수하기 위해서는 2번 과목을 이수해야 한다. www.acmicpc.net 위상정렬로 풀어야 할 것 같은 느낌이 확 ! 오는 문제 매번 선행과목 수가 더 이상 없을 경우 부터 처리해주기 때문에, 선행과목 수를 저장할 1차원 배열을 선언해준다 (int[] degree) 그리고 degree의 값이 0인 경우를 큐에 넣고, 해당 과목을 선행과목으로 두었던 다른 과목의 degree를 감소시킨다. 위 과정을 반복! [코드] import java.io.BufferedReader; import java.io...

https://www.acmicpc.net/problem/2565 2565번: 전깃줄 첫째 줄에는 두 전봇대 사이의 전깃줄의 개수가 주어진다. 전깃줄의 개수는 100 이하의 자연수이다. 둘째 줄부터 한 줄에 하나씩 전깃줄이 A전봇대와 연결되는 위치의 번호와 B전봇대와 연결되는 www.acmicpc.net 이미 개수를 구한 부분들을 탐색하면서 1. 현재 노드에 연결된 전깃줄 인덱스 > 이전 노드에 연결된 전깃줄 인덱스 2. 1의 조건을 만족하는 값들중에 연결된 전깃줄의 수가 최대인 경우 이 두 조건을 만족하는 값을 구하고 +1을 해주었다.! 나름 효율성 높인다고 HashMap 사용해서 dp 값 설정해주었다 ㅋㅋ [코드] import java.io.BufferedReader; import java.io.IO..
https://leetcode.com/problems/restore-the-array/ Restore The Array - LeetCode Can you solve this real interview question? Restore The Array - A program was supposed to print an array of integers. The program forgot to print whitespaces and the array is printed as a string of digits s and all we know is that all integers in the array leetcode.com 숫자의 일부분을 그룹으로 나누는 경우의 수를 구하는 문제! 근데 조건이 있다. 1. 각 그..

SQL 프로그래머스 2레벨 도장깨기 # 가격대 별 상품 개수 구하기 https://school.programmers.co.kr/learn/courses/30/lessons/131530 만원 단위로 가격대 별 상품 개수 구하기 Floor로 가격 내림 적용한 가상 테이블 만들고, Group으로 묶어서 count 해줌 WITH CHG AS ( SELECT PRODUCT_ID, FLOOR(PRICE/10000) * 10000 AS PRICES FROM PRODUCT GROUP BY PRICE ) SELECT FLOOR(PRICE/10000)*10000 AS PRICE_GROUP, COUNT(*) AS PRODUCTS FROM PRODUCT GROUP BY PRICE_GROUP ORDER BY PRICE_GROU..
https://www.acmicpc.net/problem/2637 2637번: 장난감 조립 첫째 줄에는 자연수 N(3 ≤ N ≤ 100)이 주어지는데, 1부터 N-1까지는 기본 부품이나 중간 부품의 번호를 나타내고, N은 완제품의 번호를 나타낸다. 그리고 그 다음 줄에는 자연수 M(3 ≤ M ≤ 100)이 주 www.acmicpc.net 거의 해본 경험이 없는 위상정렬, 열심히 공부하고 있다! 7번제품 만드는 데 4번제품 4개가 필요하고, 4번제품 만드는 데 1번제품 5개가 필요하다면? = 7번제품 만드는데 1번제품 4 * 5 = 20개가 필요하다. 위상정렬로 부모개수를 cnt 해서 올려주면 됨 [코드] import java.io.BufferedReader; import java.io.IOExceptio..