my code link is https://ideone.com/MpyS1Y
this is O(N) but i don’t know whty it is giving TLE
Tiling Problem code problem
Maps have a larger complexity as compared to arrays or vectors only, hence try avoiding maps in recursive approaches.
In the first code you were passing ordered map by value, which meant that with every recursion new map was being created and values were being copied every time recursion was being called, this led to TLE in the test cases.
The second code is iterative hence no such problem incurred.
Upon replacing map with vector in the first code it gets accepted.