← Back to problems Solve on LeetCode →

Squares of a Sorted Array

LeetCode 977 • Easy • Two Pointers

nums = [-4,-1,0,3,10][0,1,9,16,100]. Two pointers from ends; fill squares from the back.

TimeO(n)
SpaceO(1)
L: 0R: 4k: 4
Left
Right
Write (k)
L0
R4
res[ ]
Ready
Press Play or Step to walk the algorithm.