mmd,新版current 真难看,已经删除了,# PDA - 掌中宝
k*t
1 楼
Divide a list of numbers into group of consecutive numbers but their
original order should be preserved? e.g.
8,2,4,7,1,0,3,6
2,4,1,0,3 and 8,7,6
obviously in shortest time and space.
=========================================
看到一个comment,但不确定其中的find/union是否可以O(n)实现。
1. Identify range - One pass
2. Identify number of elements within each range - One pass
3. Fill destination array by maintaining starting positions of each range -
One pass of source array.
O(n) time and O(n) space
original order should be preserved? e.g.
8,2,4,7,1,0,3,6
2,4,1,0,3 and 8,7,6
obviously in shortest time and space.
=========================================
看到一个comment,但不确定其中的find/union是否可以O(n)实现。
1. Identify range - One pass
2. Identify number of elements within each range - One pass
3. Fill destination array by maintaining starting positions of each range -
One pass of source array.
O(n) time and O(n) space