본문 바로가기

연구소👨‍💻/알고리즘연구소11

[Leetcode 1052번 문제] 1052. Grumpy Bookstore Owner 문제 상황There is a bookstore owner that has a store open for n minutes. Every minute, some number of customers enter the store. You are given an integer array customers of length n where customers[i] is the number of the customer that enters the store at the start of the ith minute and all those customers leave after the end of that minute.On some minutes, the bookstore owner is grumpy. You are giv.. 2024. 6. 21.
[Leetcode 826번 문제] 826. Most Profit Assigning Work 문제 상황You have n jobs and m workers. You are given three arrays: difficulty, profit, and worker where:difficulty[i] and profit[i] are the difficulty and the profit of the ith job, andworker[j] is the ability of jth worker (i.e., the jth worker can only complete a job with difficulty at most worker[j]).Every worker can be assigned at most one job, but one job can be completed multiple times.For ex.. 2024. 6. 18.
[Leetcode 633번 문제] 633. Sum of Square Numbers 문제 상황Given a non-negative integer c, decide whether there're two integers a and b such that a2 + b2 = c.c가 두개의 제곱수의 합으로 나타낼 수 있는지 확인하라는 문제입력정수 c출력제곱수의 합으로 나타낼 수 있는지에 대한 불값과정일단 c는 제곱수의 합이기 때문에 특정c - 특정 제곱수가 제곱수인지 확인하는 문제여도됨.그럼 모든 제곱수들을 저장해놓고 그냥 해시하면 되지 않을까?대충 2 ** 16번의 계산만 하면 돼서 문제 없다고 생각했다.알고리즘 개요도 알고리즘class Solution { typedef long long ll; unordered_map container;public: bool judgeSqua.. 2024. 6. 17.
[Leetcode 330번 문제] 330. Patching Array 문제 상황Given a sorted integer array nums and an integer n, add/patch elements to the array such that any number in the range [1, n] inclusive can be formed by the sum of some elements in the array.Return the minimum number of patches required.nums의 정렬 배열이 있고 n이라는 정수를 추가할 거임, 요소를 add/patch 한다, 1부터 n까지의 모든 수를 배열안의 수로 제작할 수 있게 되는 최소의 변형 수를 구하는 문제입력1 1 nums is sorted in ascending order.1 출력배열의 조합으로 [1.. 2024. 6. 17.