TLE error after applying dp

Even after applying dp tle is coming pls help

hello @kunal81198
a) dont use array as we cannot declare array of 10^9(value of n can be upto 10^9)

use map.
b) use top down in place of bottom up because top compute only required states whereas in bottom up compute all states from 1 to n

1 Like