Minimum Common Value Leetcode Javascript Solution