Java Replace First Occurrence Leetcode 1509