May challenge REDUCE TO ONE

somebody please help me i don’t know why my solution is getting a partially correct feedback
link to my solution
https://www.codechef.com/viewsolution/24455419

ur soln has time complexity as O(T*N) i.e O(N^2)
it wont work
use memoization

instead of calculating every time, use memoization in which we store all the possible values once in an array, and now every time give the output in O(1) complexity.
Here u go

  1. : C++ Soln
  2. : Python

Hope this helps :slight_smile: