ByteDance interview question

Leetcode question: dynamic programming for alignment