Optimal Partition Of String Leetcode Questions Java