hackerrank java regex 2 duplicate words problem solution