This is one of my favourite dp optimizations. I made a tutorial on it. Here I discuss how the trick works and how you can use it. I also discuss the problem Frog 3 from atcoder dp contest.
Here is the video: Link
The code that I discuss: Link
Better template of CHT: Link
Let me know if you like the tutorial or not :)