Logical Design Problems Leetcode Javascript