There is an array of n elements where any element is a natural number. To find a sum if present in the array without duplication while adding
Approach
- Remove all elements greater than the sum
- Sort the array in descending order
- Setting currentsum to 0
- Loop i where i = first element of array through last
- If currentsum + i <= sum then currentsum += i
- If currentsum == sum then print true
- Else print false
Is there any issues in this approach or is there test case that can give wrong answers.