목록언어/JAVA
Step-by-Step
https://leetcode.com/problems/find-the-difference/?envType=daily-question&envId=2023-09-25 LeetCode - The World's Leading Online Programming Learning Platform 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 charAt으로 비교하면 시간초과난다. [시간초과 코드] class Solution { public char findTheDifference(Strin..
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..