본문 바로가기
728x90
반응형

coding3

[leetcode] Remove Duplicates from Sorted Array (c++) Problem Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. Clarification: Confused why the returned value is an integer but your answer is an array? Note that the input array is passed in by refer.. 2021. 3. 7.
[Codility] Lesson15 - Caterpillar method: Abs Distinct Problem A non-empty array A consisting of N numbers is given. The array is sorted in non-decreasing order. The absolute distinct count of this array is the number of distinct absolute values among the elements of the array. For example, consider array A such that: A[0] = -5 A[1] = -3 A[2] = -1 A[3] = 0 A[4] = 3 A[5] = 6 The absolute distinct count of this array is 5, because there are 5 distinct.. 2021. 2. 15.
[백준] 1202 보석도둑 (Greedy Algorithm) How to solve *priority queue 를 사용! 1. jewerly를 보석 무게 기준 기준 오름차순 정렬합니다. 2. 가방을 작은것 부터 채우기 위해 오름차순 정렬합니다. 3. K개의 가방을 차례로 채웁니다. 4. 가방의 무게보다 작은 주얼리는 모두 priority queue(pq)에 넣어줍니다. 5. 넣은 주얼리 중 가장 비싼 주얼리(pq에 내림차순으로 정렬되어있으므로 pq.top())를 선택합니다.(res에 더해줌) 6. 넣은 주얼리를 pop하고, 다음 가방을 채웁니다. Problem 시간 제한메모리 제한제출정답맞은 사람정답 비율 1 초 256 MB 9203 2203 1562 23.753% 문제 세계적인 도둑 상덕이는 보석점을 털기로 결심했다. 상덕이가 털 보석점에는 보석이 총 N개 있.. 2020. 8. 25.
728x90
반응형