Right Triangles Leetcode Javascript Solution