Partitioning (转载)# Programming - 葵花宝典
i*0
1 楼
【 以下文字转载自 JobHunting 讨论区 】
发信人: iq300 (iq300), 信区: JobHunting
标 题: Partitioning
发信站: BBS 未名空间站 (Wed Mar 5 17:27:35 2008)
Partitioning
Given an array of balls, which can be one of two colors (RED or BLUE), write
a function that partitions the array in-place such that on exit from the
function all the balls of the same color are contiguous. It does not matter
whether the red or blue balls come first. The return value from the function
is the index of the first ball of the second color. If there
发信人: iq300 (iq300), 信区: JobHunting
标 题: Partitioning
发信站: BBS 未名空间站 (Wed Mar 5 17:27:35 2008)
Partitioning
Given an array of balls, which can be one of two colors (RED or BLUE), write
a function that partitions the array in-place such that on exit from the
function all the balls of the same color are contiguous. It does not matter
whether the red or blue balls come first. The return value from the function
is the index of the first ball of the second color. If there