Finding whether a sum of numbers in a set generate another number

72 Views Asked by At

I have a set of numbers $\{a_1,\dots,a_n\}$ and another number $k$. I need to find whether sum of any combination of numbers in the set produces $k$. It can be $a_1 + a_2$ or $a_1 + a_2 + a_3 + a_7$. I don't want the actual numbers itself but just a yes or no answer on whether possible or not. Is there any efficient algorithm other than the brute force one to check each permutation?