【问题标题】:Leetcode 21. Merge Two Sorted ListsLeetcode 21. 合并两个排序列表
【发布时间】:2022-08-16 22:45:45
【问题描述】:

这可能听起来有点愚蠢,但我想知道为什么它不会接受这样的提交:

var mergeTwoLists = function(list1, list2) {
  const mergerarr = list1.concat(list2);
  const mergesortfinal = mergerarr.sort((a, b) => a - b);
  return mergesortfinal;
};

    标签: javascript arrays algorithm sorting


    【解决方案1】:

    问题(以及数据结构)是关于链表的,而不是数组。您使用的函数用于数组。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-12
      • 1970-01-01
      • 1970-01-01
      • 2022-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多