Java Replace First Occurrence Leetcode