Java Replace First Occurrence Leetcode 150