【发布时间】:2023-04-06 22:02:01
【问题描述】:
我有一个大约 20K 项的排序列表 v。 我想在第一个 v[i]>K
处将其拆分为 2 个列表N:20000;
v:asc N?100000; / N random numbers sorted
K:200; / threshold
v1:v[where v<=K]; / "v<=K" has O(N) complexity, "where" has O(N) too
v2:(count v1) _ v; / list is sorted, this holds.
问题:如何避免v
这是与性能相关的问题。 (注意忽略在“asc”上花费的时间。)
【问题讨论】: