What's wrong in this https://ide.codingblocks.com/s/412691

what’s wrong in this https://ide.codingblocks.com/s/412691

You ll get java.lang.OutOfMemoryError
use Top-down dp and HashMap, it will work

pls explain why we should unordered_map here

why we cant use array

with the leaking code constantly used, the “cached” results end up consuming a lot of Java heap space and when the leaked memory fills all of the available memory in the heap region and Garbage Collection is not able to clean it, the java.lang.OutOfMemoryError:Java heap space is thrown. That is why we prefer Hashmap over array