Java String Replace First Occurrence Leetcode Problem