Given a 1D array A of N 32-bit floating point numbers, compact all
positive elements (A[i] > 0) to the front of the output array out,
preserving their original relative order. Fill any remaining positions with 0.0.
Stream compaction is a fundamental GPU primitive used throughout rendering, sparse computation,
and collision detection.
solve function signature must remain unchangedout must contain the k elements of
A where A[i] > 0, in their original order
out must be 0.0A[i] = 0.0 are not selectedInput: A = [1.0, -2.0, 3.0, 0.0, -1.0, 4.0] Output: out = [1.0, 3.0, 4.0, 0.0, 0.0, 0.0]
N ≤ 100,000,000A[i] ≤ 1000.0out is pre-allocated with N elements, initialised to 0.0N = 50,000,000