Pattern Program Java Leetcode