There is dfs with about 500*1000 nodes in this problem (so there can be a long chain). I have Runtime Error because of this. So I decided to set heap size to 1<<27. The surprise for me is that Java 8 solution passes, while the same Java 11 solution does not. And it seems that Java 11 even eats twice more memory. Can you explain the reasons, or maybe refer me to some resources about this, please?