Array manipulation

can u explain me what other method than brute force can i use to solve this problem

Yes brute force method has very high complexity, around O(n^3). You can either use recursion or, the best and innovative way is to think of the array or a string in binary, so for an array of size of 4, you will have 16 combinations. 0000, 0001 and so on. compare each of them with jth index and if the particular bit is set, print that number.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.