Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
您有 n 个已排序的链表,每个链表的大小为 n。链表引用存储在数组中。将 n 个链表合并为单个排序链表的有效算法是什么?
因为它们都是排序的:
null
这是最有效的方法吗?
只需将它们全部链接在一起(或将它们转储到一个列表中)并使用一般排序。这将为您提供 nlog(n) 性能。你的方式是n^2。