Can't figure this one out. You cannot use Python builtins. you must use StaticArray to accomplish this. StaticArrays have 3 methods, get, set, size. You must specify the size of the StaticArray when u initialize it, like this: arr = StaticArray(10) <-- size 10 StaticArray Input array is arrumed to be sorted (but could be something like -3, -2, -2, 0, 1, 2, 3, which would return 9, 4, 4, 0, 1, 4, 9, and that must be sorted! Solution must use Number Sort. def sorted_squares(arr: StaticArray) -> StaticArray: """ returns a new StaticArray with squares of the values from the original array, sorted in non-descending (smallest to largest) order. Precondition: Input StaticArray must be sorted! """ python code here
Can't figure this one out. You cannot use Python builtins. you must use StaticArray to accomplish this. StaticArrays have 3 methods, get, set, size. You must specify the size of the StaticArray when u initialize it, like this: arr = StaticArray(10) <-- size 10 StaticArray
Input array is arrumed to be sorted (but could be something like -3, -2, -2, 0, 1, 2, 3, which would return 9, 4, 4, 0, 1, 4, 9, and that must be sorted!
Solution must use Number Sort.
def sorted_squares(arr: StaticArray) -> StaticArray: """ returns a new StaticArray with squares of the values from the original array, sorted in non-descending (smallest to largest) order. Precondition: Input StaticArray must be sorted! """
python code here
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images