The JavaScript test cases are completely messed up


  • 0
    A

    JavaScript test case #25 claims inputs for l1 and l2 are [2] and [1] respectively. After examining l1 and l2 however what I see is:

    l1 = {value: undefined, next: null}
    l2 = {value: undefined, next: null}

    The system still expects an output of [1, 2] (as an array!!!).

    Completely broken and unworkable.


  • 0
    K

    @alexcs17 Are you sure it's value instead of val?

    You can use following method for ListNode. (I know it's ugly.)

    
    ListNode.prototype.print = function print() {
      let self = this;
      const array = [];
      while (self !== null) {
        array.push(self.val);
        self = self.next;
      }
      console.log(array);
      console.log(array.toString());
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.