Are there some corner cases that needs to be maintained?
My solution is getting WA and I do not know why. I have D array from tutorial in map. Numbers are increasing from index Ki to Ki-1. So I’m calculating values for these indexes and I maintain min and max, that’s all…
Btw: it’s not good, that same algorithm in Java is getting TLE :-/