Shortest Path Leetcode String Pattern Program