scan leet-code algorithm questions online. Sometimes you don"t know how to debug when something goes wrong. For example, this question:
merging two ordered linked lists
the code template is as follows:
/**
* Definition for singly-linked list.
* function ListNode(val) {
* this.val = val;
* this.next = null;
* }
*/
/**
* @param {ListNode} l1
* @param {ListNode} l2
* @return {ListNode}
*/
var mergeTwoLists = function(l1, l2) {
};
Test input is
[1,2,4]
[1,3,4]
what is depressing is that it is obvious that L1 and L2 are passed in two arrays, but it seems strange that the code has become an instantiated object of ListNode. Can ListNode be used directly in the code? Write their own code can not run, and can not be debugged online, completely inexplicable!