본문 바로가기
728x90
반응형

codility25

[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] Lesson16 - Greedy algorithms: TieRopes Problem There are N ropes numbered from 0 to N − 1, whose lengths are given in an array A, lying on the floor in a line. For each I (0 ≤ I < N), the length of rope I on the line is A[I]. We say that two ropes I and I + 1 are adjacent. Two adjacent ropes can be tied together with a knot, and the length of the tied rope is the sum of lengths of both ropes. The resulting new rope can then be tied a.. 2021. 2. 25.
[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.
[Codility] Lesson16 - Greedy algorithms: Max Nonoverlapping Segments Problem Located on a line are N segments, numbered from 0 to N − 1, whose positions are given in arrays A and B. For each I (0 ≤ I < N) the position of segment I is from A[I] to B[I] (inclusive). The segments are sorted by their ends, which means that B[K] ≤ B[K + 1] for K such that 0 ≤ K < N − 1. Two segments I and J, such that I ≠ J, are overlapping if they share at least one common point. In .. 2021. 2. 10.
728x90
반응형