Prefix Suffix Leetcode Problem - C#