Not able to solve for 1e9

code is showing segmentation error when solving for 1e9 otherwise compiling.

hi @akshatkaush use a hash-map to maintain the dp states to optimise the memory. We dont actually need ALL of the 1e9 states, so using a dp array in this case will be inefficient

1 Like