【发布时间】:2013-06-04 11:17:18
【问题描述】:
假设您有 3 个不同项目的列表。您必须按索引从这些列表之一中返回项目。索引是从 0 到 Count(<all lists items>) 的数字。
例子:
lists 1: 10 items;
lists 2: 5 item;
lists 3: 1 item;
因此,索引应该在 0 到 15 之间。按索引逐项:
0: lists 1, item 0;
1: lists 2, item 0:
2: lists 3, item 0;
3: lists 1, item 1;
4: lists 2, item 1;
5: lists 1, item 2;
6: lists 2, item 2;
7: lists 1, item 3;
8: lists 2, item 3;
9: lists 1, item 4;
10: lists 2, item 4;
11: lists 1, item 5;
12: lists 1, item 6;
13: lists 1, item 7;
14: lists 1, item 8;
15: lists 1, item 9;
(对不起,完整的结果。这是为了我自己的理解检查)。
最好的方法是:
- 确定要使用哪些列表?
- 要使用列表中的哪个索引来获取项目?
可能的解决方案:
- 将所有列表中的所有项目放入一个大列表中。大列表中的每个项目都应包含:列表索引;列表中的项目(或项目索引);
- 当索引到达时,简单地从大列表中返回项目。
【问题讨论】:
-
所以你想在列表轮换中索引项目。有点像具有不等大小磁盘的 RAID 0?
-
是的。听起来像 RAID 0。
-
by "列表中的哪个索引用于获取项目?"你的意思是你想把那些小列表的索引转换成大的?还是相反?
-
小列表的索引和该列表的索引。
-
这个问题背后的要求是什么?对我来说听起来很奇怪......
标签: c# algorithm collections