본문 바로가기
728x90
반응형

algorithm8

[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.
[Codility] Lesson12 - Euclidean algorithm: Common Prime Divisors Problem A prime is a positive integer X that has exactly two distinct divisors: 1 and X. The first few prime integers are 2, 3, 5, 7, 11 and 13. A prime D is called a prime divisor of a positive integer P if there exists a positive integer K such that D * K = P. For example, 2 and 5 are prime divisors of 20. You are given two positive integers N and M. The goal is to check whether the sets of pr.. 2021. 2. 9.
[Codility] Lesson10 - Prime and composite numbers: MinPerimeterRectangle Problem n integer N is given, representing the area of some rectangle. The area of a rectangle whose sides are of length A and B is A * B, and the perimeter is 2 * (A + B). The goal is to find the minimal perimeter of any rectangle whose area equals N. The sides of this rectangle should be only integers. For example, given integer N = 30, rectangles of area 30 are: (1, 30), with a perimeter of 6.. 2021. 1. 30.
728x90
반응형