my code:
https://ide.codingblocks.com/s/41649
question link:
https://hack.codingblocks.com/contests/c/512/875
PLEASE SHOW ME MY MISTAKE …
MY CODE RUNS FINE ON ONLINE IDE
my code:
https://ide.codingblocks.com/s/41649
question link:
https://hack.codingblocks.com/contests/c/512/875
PLEASE SHOW ME MY MISTAKE …
MY CODE RUNS FINE ON ONLINE IDE
Your logic is right.
But your code takes very long time to run for bigger cases like 41, 42,…
The complexity of your code is O(2^n) as you are making 2 calls in each recursive call, which is not a good complexity. Try to improve it.
CAN U SUGGEST ME AN APPROACH CAUSE AM NOT ABLE TO THINK OF ONE WITH BETTER TIME COMPLEXITY
Think about Dynamic programming Here .