Count Pairs Of Nodes Leetcode Problems Javascript