Infosys interview question

Minimum Prefix Problem from leetcode.