Given that we already know the size of the output array,
we don't even need to scan for where the sign change
happens, since we can fill it in in reverse.
Simply init i & j to start and end,
and do 2-way merge inward,
emitting squares as you go.
At some point the two indexes will locate
where the sign change is, and then we're done.
There are at most 10_000 elements,
and their absolute values shall be at most 10_000.
It's not hard to allocate a containercontainer of that size.
Simply store absolute values of the inputs,
and then read them out in sequence.
No \$\log n\$ term involved at all.
Is this cheating?
Yes.
Kind of.
The key is to figure out the rules, and play within them.
(And benchmark against the previous approach.
Which this won't be competitive with,
for most input sizes.)