1 votes 1 votes WAP where smallest subarrays with sum greater than x? Say an array={1,5,6,2,45,17}; Now, x=60 Now we have to find smallest subarray which is greater than x Programming in C programming-in-c output + – srestha asked Mar 23, 2017 • retagged Jun 4, 2017 by Arjun srestha 1.3k views answer comment Share Follow See all 9 Comments See all 9 9 Comments reply Show 6 previous comments akash.dinkar12 commented Mar 23, 2017 reply Follow Share cant we do in this way that find the subarrays of Size 1, size 2 ,..... Size N an find the corresponding sum of each subarrays and then compare with each of subarray start from Size1 Subarray and so on..with the given value of X and if any smallest subarray sum would be greater than X then return that smallest subarray??????? 0 votes 0 votes dd commented Mar 23, 2017 reply Follow Share @ srestha..I said general Idea. I could draw a zig-zag pattern curve, then it would be difficult the visualize. I got your point of discrete sum. 0 votes 0 votes srestha commented Mar 23, 2017 reply Follow Share So, now how algorithm go? why u think about decreasing curve? I am not getting that point 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes To solve a single program there are many algorithms. Best solution always consider which has best complexity. this problem is a little bit tricky due to subarray otherwise nothing in this problem 3 step solution(sorting+comparison+print). WHAT IS SUBARRAY(http://www.geeksforgeeks.org/subarraysubstring-vs-subsequence-and-programs-to-generate-them/) 1 soln. http://www.geeksforgeeks.org/minimum-length-subarray-sum-greater-given-value/ learner_geek answered Apr 9, 2017 • edited Apr 9, 2017 by learner_geek learner_geek comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes we can apply sorting alogorithm like quick sort. and choose the number contineously in the array upto the value reaches to greater then 60 and stop then so its complexity wll O(nlogn) akankshadewangan24 answered Apr 19, 2017 akankshadewangan24 comment Share Follow See all 0 reply Please log in or register to add a comment.