Back to course home
0% completed
Vote For New Content
can I just go through the array and do i**2 and then use the python sort() funct...
Charlie Jiang
Jan 6, 2023
can I just go through the array and do i**2 and then use the python sort() function? Wouldn't this be easier than the two pointer approach?
0
0
Comments
Comments
C
Charlie Jiang3 years ago
where is the systemdesign here are they all gone?
Design Gurus3 years ago
Yes, you can do this, but it won't be efficient.
Due to sorting, the time complexity of your algorithm will be O(N*logN) and a space complexity of O(N).
The algorithm we suggested take O(N) time and space.
On this page
Problem Statement
Try it yourself