목록언어/JAVA
Step-by-Step
https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/ Longest Substring with At Least K Repeating Characters - LeetCode Longest Substring with At Least K Repeating Characters - Given a string s and an integer k, return the length of the longest substring of s such that the frequency of each character in this substring is greater than or equal to k. Example 1: Inpu..
https://leetcode.com/problems/minimum-distance-between-bst-nodes/ Minimum Distance Between BST Nodes - LeetCode Minimum Distance Between BST Nodes - Given the root of a Binary Search Tree (BST), return the minimum difference between the values of any two different nodes in the tree. Example 1: [https://assets.leetcode.com/uploads/2021/02/05/bst1.jpg] Input: root leetcode.com Tree를 DFS로 돌면서 val 값..
https://leetcode.com/problems/add-binary/ Add Binary - LeetCode Can you solve this real interview question? Add Binary - Given two binary strings a and b, return their sum as a binary string. Example 1: Input: a = "11", b = "1" Output: "100" Example 2: Input: a = "1010", b = "1011" Output: "10101" Constraints: * leetcode.com 2진수 ↔ 10진수 (Binary to Decimal / Decimal to Binary) 방법은 쓰지말자 범위를 보면 오버플로..

https://leetcode.com/problems/naming-a-company/description/ Naming a Company - LeetCode Naming a Company - You are given an array of strings ideas that represents a list of names to be used in the process of naming a company. The process of naming a company is as follows: 1. Choose 2 distinct names from ideas, call them ideaA and ideaB. 2. Sw leetcode.com 이게 왜 Hard인지 첫 제출하고 느낀 문제 총 3가지로 시도했는데, 1..
https://leetcode.com/problems/fruit-into-baskets/ Fruit Into Baskets - LeetCode Fruit Into Baskets - You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array fruits where fruits[i] is the type of fruit the ith tree produces. You want to collect as much frui leetcode.com 백준은 유형별로 풀 수 있는 장점이 있지만, 하다 보면 점점 풀고 싶은 것만 풀고, 쉽..
https://www.acmicpc.net/problem/14908 14908번: 구두 수선공 최소 보상금을 지불하는 작업 순서를 출력해야 한다. 모든 작업은 입력에서의 번호(1~N)로 표시해야 한다. 모든 정수는 한 줄로 표시해야 하며, 각 작업은 공백 문자로 구분한다. 여러 가지 해답 www.acmicpc.net 정렬 조건 1. 일의 능률이 높은 순 (T/S) 2. i가 빠른 순 compare의 리턴값은 int 이기 때문에 if로 비교해서 1 or -1을 리턴하도록 하였다 PQ로 로직을 만들어 데이터를 넣고, 차근차근 빼서 출력해주면 됨 [코드] package BOJ; import java.io.BufferedReader; import java.io.IOException; import java.io...
https://www.acmicpc.net/problem/1781 1781번: 컵라면 상욱 조교는 동호에게 N개의 문제를 주고서, 각각의 문제를 풀었을 때 컵라면을 몇 개 줄 것인지 제시 하였다. 하지만 동호의 찌를듯한 자신감에 소심한 상욱 조교는 각각의 문제에 대해 데드라 www.acmicpc.net 여러 가지 반례를 생각해보아야 하는 문제 이 반례를 보고 도움이 많이 됐다 → https://www.acmicpc.net/board/view/97635 예를 들어) deadLine 1 cup 2 deadLine 2 cup 4 / deadLine 2 cup 5 인 경우 데드라인 1에서 1개, 데드라인 2에서 1개를 선택하면 cup이 2+5 = 7이지만, 데드라인 2에서 2개를 선택하면 cup이 4+5 = 9..
https://www.acmicpc.net/problem/3661 3661번: 생일 선물 각 테스트 케이스마다 각 사람이 내야 하는 금액을 출력한다. 만약, 공정하게 선물을 사는 방법이 없다면 IMPOSSIBLE을 출력한다. www.acmicpc.net 돈 분배 과정에서 이미 할당량을 채운 객체를 고려해서 메모리 초과가 났던 문제 더 이상 지불할 수 없는 경우를 Array에서 제거하니 통과되었다 [주의할 점] 1. 지불 용이 금액이 높은 사람이 우선순위 - 마지막에 남은 금액을 분배할 때, 지불 용이 금액이 높은 사람을 우선적으로 선택함 - Collections.sort를 이용하여 지불 용이 금액이 높은 사람을 정렬하였음 2. 지불한 금액