Given n integers a1,a2..an and some integer S. To test whether there exists xi belongs to {0,1} such that:
**S = Summation(xi*ai) [i=0 to n]**
Test whether when using (x1,x2,..xn) := (0,0,..,0) in the above eqn, this would work. Then continue with testing (x1,x2,....,xn) :=,(0,0,0,...1), etc., until finally testing (x1,x2,....xn) := (1,1,.....1). If the above eqn is satisfied for one of these tests, then return True, else False.
1) Analyze the time complexity? 2) Does the algo take polynomial time?