Java Replace First Occurrence Leetcode Problems