Leetcode Javascript Class Inheritance Representation Theory