How to optimally divide an array into two subarrays so that sum of elements in both are same, otherwise give an error?

There exists a solution, which involves dynamic programming, that runs in O(n*TotalSum), where n is the number of elements in the array and TotalSum is their total sum. The first part consists in calculating the set of all numbers that can be created by adding elements to the array. For an array of size n, … Read more

How to find the kth smallest element in the union of two sorted arrays?

I hope I am not answering your homework, as it has been over a year since this question was asked. Here is a tail recursive solution that will take log(len(a)+len(b)) time. Assumption: The inputs are correct, i.e., k is in the range [0, len(a)+len(b)]. Base cases: If length of one of the arrays is 0, the answer … Read more

Difference between Divide and Conquer Algo and Dynamic Programming

Divide and Conquer Divide and Conquer works by dividing the problem into sub-problems, conquer each sub-problem recursively and combine these solutions. Dynamic Programming Dynamic Programming is a technique for solving problems with overlapping subproblems. Each sub-problem is solved only once and the result of each sub-problem is stored in a table ( generally implemented as … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)