The intended solution is O(2^M*N) if you look at the constraints. Polynomial version will simply be too tough and out of syllabus for Foundation.
1 Like
if you like java and understand big integers… simple with recursion