Minimum Common Value Leetcode Problem