Problems Boxes_through_a_Tunnel.c Calculate_the_N_Number.c Dynamic_Array_in_C.c FilledOrders.c Permutations_of_Strings.c Post_Transition.c Small_Triangles_Large_Triangles.c Students_Marks_Sum.c Variadic_Function_in_C.c LICENSE README.mdBreadcrumbs HackerRank_C /Problems/...
/** * https://www.hackerrank.com/challenges/dynamic-array/problem * */ class DynamicArray { var lastAnswer = 0 var answerList: ArrayList<Int>? = null var seqs: ArrayList<ArrayList<Int>>? = null fun dynamicArray(n: Int, queries: Array<Array<Int>>): Array<Int> { seqs = ArrayList<...
/** * https://www.hackerrank.com/challenges/dynamic-array/problem * */ class DynamicArray { var lastAnswer = 0 var answerList: ArrayList<Int>? = null var seqs: ArrayList<ArrayList<Int>>? = null fun dynamicArray(n: Int, queries: Array<Array<Int>>): Array<Int> { seqs = ArrayList<...
However, in my solution dp state was dp[mask] = a number from the given array such that . So we have base cases , for other masks initialize with 0.Now, for each array elements you need to find out another number from the array, such that their AND is 0. Note that the ...
Where is my logic wrong in this dynamic programming problem? I'm trying to solve https://www.hackerrank.com/challenges/summing-pieces and I think I have come up with an O(n) solution although the numbers aren't coming out exactly right. The problem is essentially to find a sum like ABC...
In the divide and conquer optimization ,can we always say that it is possible to use in a system where we have to minimize the sum of cost of k continuous segments( such that their union is the whole array and their intersection is null set) such that the cost of segment increases with...