/*help me to identify my error (giving wrong ans)*/

pls allign the code properly, its quite tough to understand. best will be if you can give a link of your submission

moreover , regarding the question .

- first sort the array.
- store presums in array
- start rolling over from 1-arr[n-1].
- use the presums + the number*(no greater then them) to check.

regarding your solution , i find you are doing it in O(n*n).do it in O(nlogn).

here is a link to my code.

do upvote if u understand , else ask .

https://www.codechef.com/viewsolution/14377928

oh gosssh , i missed it but i guess the weak test cases made it a right answer

hey here is my accepted solution and i hope my code is easy to understand https://www.codechef.com/viewsolution/14370619

please ask if you have any doubt.

Thanks, Yeah i understood question in a different Way

But didnt the Q state that-

```
to find a number K **from array A** such that if all elements in A
```

1 Like