Rajesh
BAN USERInterested in innovation and patent filing.
interested in problem solving
Add up all the Elements in the array which is say total. Construct an array , A[total] and find how many ways to sum up the value i ( i from 0 to total) and enter in A[total] array using DP(coin problem)
Now , start at A[total/2] and check if the value is 0 or not . If not zero , total/2 is the value and elements used to form total/2 is the solution. If it is zero, check A[total/2-1] and A[total/2+1] and check it is zero or not. Move in this fashion in both direction till you find an entry in Array
A which is not zero.
Find total = n(n-1)/2 , where n is the number of characters in the string. This gives the number of all continous substrings.
consider i=1, calculate an end point (which will be lesser than n) till which the condition is satisfied(string([i,i+1],string[i,i+2],.....string[i,end] will satisfy the condition). Find (n-end) and subract it from total. Now increment the value of i and start finding the same end , but need not start from i+1 to find the end, but can start from the previous 'end' found. Do this till i reaches n.
1) Use knapsack problem to find the minimum value(instead of maximum) for Weight W. In the original algo instead of taking maximum value take minimum value for each Array[i] , 0<i<=W.
2) Now for each value of n, find the minimum index i in Array such that i+w[n]> W and note the value as Array[i]+v[n]. Update this value if the old value is greater than the new value
1.Do a k-way merge. Use k pointers to point to the start of each list.
- Rajesh April 01, 20132.Find the min and max elements among these k elements and find the difference as range (min and max are elements of range). If range is less than previous range, update it
3.Move to the next index in the list having the minimum value. Go to step 2