Upstox interview question

Word break problem on leetcode