Double pointer is over!
int* sortedSquares(int* A, int ASize, int* returnSize) {
int* ans = malloc(sizeof(int) * ASize);
*returnSize = ASize;
for (int i = 0, j = ASize - 1, pos = ASize - 1; i <= j;)
{
if (A[i] * A[i] > A[j] * A[j])
{
ans[pos] = A[i] * A[i];
++i;
}
else
{
ans[pos] = A[j] * A[j];
--j;
}
--pos;
}
return ans;
}