for (int i=0; i<arr.size(); i++) {
    int sum=0;
    for (int j=i; j<arr.size() && sum<=k ; j++)
        sum = sum + arr[j];
    if (sum == k) break;
}

An O(n^2) solution (Just to prove that a solution does exist even
though a little inefficient).
Can we at least improve upon the above algo to remove unwanted
calculations etc.?


On Jul 4, 11:16 pm, jalaj jaiswal <jalaj.jaiswa...@gmail.com> wrote:
> find the subsequence in an array which sum to k
>
> --
> With Regards,
> Jalaj Jaiswal
> +919026283397
> B.TECH IT
> IIIT ALLAHABAD

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to