retagged by
1,320 views
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
retagged by

2 Answers

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/

edited by
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)

Related questions

1 votes
1 votes
1 answer
1
Desert_Warrior asked May 15, 2016
2,614 views
main() { int arr2D[3][3]; printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); }