Refactor 'decode ways' with bottom-up DP approach.