mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-12-26 21:58:56 +01:00
Update data_structures/arrays/sort_squares_of_an_array.rb
Co-authored-by: Vitor Oliveira <vbrazo@gmail.com>
This commit is contained in:
parent
92f09581f6
commit
f9e7cd677d
1 changed files with 3 additions and 2 deletions
|
@ -36,7 +36,8 @@ def bubble_sort(array)
|
|||
end
|
||||
|
||||
#
|
||||
# Time complexity analysis for Approach 1 & 2
|
||||
# Time complexity: O(n logn), where n is the length of the array.
|
||||
# Space complexity: O(n) or O(logn)
|
||||
#
|
||||
|
||||
def sorted_squares(nums)
|
||||
|
@ -83,4 +84,4 @@ def sorted_squares(nums)
|
|||
output
|
||||
end
|
||||
|
||||
print(sorted_squares([4, -1, -9, 2]))
|
||||
print(sorted_squares([4, -1, -9, 2]))
|
||||
|
|
Loading…
Reference in a new issue