본문 바로가기

leetcode11

[Leetcode 2601번 문제] 2601. Prime Subtraction Operation 문제 상황You are given a 0-indexed integer array nums of length n.You can perform the following operation as many times as you want:Pick an index i that you haven’t picked before, and pick a prime p strictly less than nums[i], then subtract p from nums[i].Return true if you can make nums a strictly increasing array using the above operation and false otherwise.A strictly increasing array is an array.. 2024. 11. 11.
[Leetcode 2955번 문제]2955. Number of Same-End Substrings 문제 상황You are given a 0-indexed string s, and a 2D array of integers queries, where queries[i] = [li, ri] indicates a substring of s starting from the index li and ending at the index ri (both inclusive), i.e. s[li..ri].각각의 쿼리가 subarrayReturn an array ans where ans[i] is the number of same-end substrings of queries[i].same-end?A 0-indexed string t of length n is called same-end if it has the same.. 2024. 11. 10.
[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 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.