Untitled
4 years ago in Plain Text
var TEST = function () {
function _getNum(node) {
let str = '';
while (node && node !== 0) {
str = node.val + str;
node = node.next;
}
return parseInt(str) || 0;
}
function _getNode(str) {
let node = 0;
let len = str.length;
for (var i=0; i<len; ++i) {
node = new ListNode(str[i], node);
}
return node;
}
return {
exec: function (l1, l2) {
return _getNode(_getNum(l1) + _getNum(l2) + '');
}
};
}();