CS/Algorithm3 [#14 Binary Search] NailingPlanks You are given two non-empty arrays A and B consisting of N integers. These arrays represent N planks. More precisely, A[K] is the start and B[K] the end of the K−th plank.Next, you are given a non-empty array C consisting of M integers. This array represents M nails. More precisely, C[I] is the position where you can hammer in the I−th nail.We say that a plank (A[K], B[K]) is nailed if there exi.. 2025. 4. 4. [#10 Prime and composite numbers] Flags - Binary Search A non-empty array A consisting of N integers is given.A peak is an array element which is larger than its neighbours. More precisely, it is an index P such that 0 A[P + 1].For example, the following array A:A[0] = 1A[1] = 5A[2] = 3A[3] = 4A[4] = 3A[5] = 4A[6] = 1A[7] = 2A[8] = 3A[9] = 4A[10] = 6A[11] = 2has exactly four peaks: elements 1, 3, 5 and 10.You are going on a trip to a range of mounta.. 2025. 4. 3. [#9 Maximum slice problem] MaxDoubleSliceSum - Kadane Algorithm The goal is to find the maximal sum of any double slice.Write a function:def solution(A)that, given a non-empty array A consisting of N integers, returns the maximal sum of any double slice.For example, given:A[0] = 3A[1] = 2A[2] = 6A[3] = -1A[4] = 4A[5] = 5A[6] = -1A[7] = 2the function should return 17, because no double slice of array A has a sum of greater than 17.Write an efficient algorithm.. 2025. 4. 3. 이전 1 다음