[LeetCode] 3020. Find the Maximum Number of Elements in Subset
·
Algorithm/Review
https://leetcode.com/problems/find-the-maximum-number-of-elements-in-subset/description/?envType=daily-question&envId=2026-06-27 Find the Maximum Number of Elements in Subset - LeetCodeCan you solve this real interview question? Find the Maximum Number of Elements in Subset - You are given an array of positive integers nums. You need to select a subset of nums which satisfies the following condi..
[Algorithm] 이분매칭(Bipartite Matching)
·
Algorithm
N명의 사람이 M개의 일을 해야하는데 각 일에는 한사람만 할당이 가능하다.이때 최대한 일을 많이 처리하기 위해서 몇명의 사람을 할당할 수 있을까? 해당 문제를 풀기 위해서 완전 탐색등을 사용할 수 있다.하지만 N과 M이 커질경우 해당 방식도 기하급수적으로 커진다. 그렇다면 이런 문제를 어떻게 풀어야할까?? 여기서 나오는 것이 이분 매칭이다. 이분 그래프인접한 정점끼리 서로 다른 색으로 칠해서 모든 정점을 두 가지 색으로만 칠할 수 있는 그래프이며그래프의 모든 정점이 두 그룹으로 나눠지고 서로 다른 그룹의 정점이 간선으로 연결돼 있는 그래프를 의미한다. 이분 매칭아래와 같이 A, B, C, D, E라는 사원이 있고 1, 2, 3, 4, 5라는 총 5개의 일이 있다고 가정해보자 이때 A라는 사원은 2번과 ..
[LeetCode] 410. Split Array Largest Sum
·
Algorithm/Review
https://leetcode.com/problems/split-array-largest-sum/description/ Split Array Largest Sum - LeetCodeCan you solve this real interview question? Split Array Largest Sum - Given an integer array nums and an integer k, split nums into k non-empty subarrays such that the largest sum of any subarray is minimized. Return the minimized largest sum of the split.leetcode.com 문제정의1. nums라는 배열과 정수 k가 주어..
[LeetCode] Binary Lifiting를 사용한 최소공통조상 최적화
·
Algorithm
최근 LeetCode 문제를 풀며 최소공통조상 비슷한 문제가 나와 쉽게 풀었다고 생각했다. https://leetcode.com/problems/number-of-ways-to-assign-edge-weights-ii/description/?envType=daily-question&envId=2026-06-12 Number of Ways to Assign Edge Weights II - LeetCodeCan you solve this real interview question? Number of Ways to Assign Edge Weights II - There is an undirected tree with n nodes labeled from 1 to n, rooted at node 1. The t..
[백준] 2306번 유전자 (C++)
·
Algorithm/Review
https://www.acmicpc.net/problem/2306 최근 dp유형이 좀 많이 약한것 같아서 다양한 문제들을 풀면서 dp에 익숙해지기로 하였다. 이 문제는 문자열이 주어지고 (a, t), (g, c) 라는 가장 짧은 KOI 유전자가 존재하며KOI 유전자에 겹쳐서 성립하는 경우도 KOI 유전자라고 하며 이때 최대 길이를 구하는 문제이다. 문제 조건에 최대 길이의 KOI 문자열을 구하기 위해서 문자 중간중간을 삭제할 수 있으며 제한은 없다. 따라서 내가 해당 문자를 선택하고 버리는 것에 따라서 미래에 영향을 주기 때문에 모든 경우의 수를 구하며 최적화를 해야한다. 따라서 dp 테이블을 정의해야한다. 스스로 해결: ❌ dp[i][j] = i구간부터 j구간까지 KOI 문자열의 최대 길이로 식을 세..