File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ ##==================================
2
+ ## Leetcode
3
+ ## Student: Vandit Jyotindra Gajjar
4
+ ## Year: 2020
5
+ ## Problem: 977
6
+ ## Problem Name: Squares of a Sorted Array
7
+ ##===================================
8
+ #
9
+ #Given an array of integers A sorted in non-decreasing order,
10
+ #return an array of the squares of each number, also in sorted non-decreasing order.
11
+ #
12
+ #Example 1:
13
+ #
14
+ #Input: [-4,-1,0,3,10]
15
+ #Output: [0,1,9,16,100]
16
+ #Example 2:
17
+ #
18
+ #Input: [-7,-3,2,3,11]
19
+ #Output: [4,9,9,49,121]
20
+ class Solution :
21
+ def sortedSquares (self , A ):
22
+ for i in range (len (A )): #Loop through A
23
+ A [i ] = A [i ]* A [i ] #Update the list by taking elements square
24
+ A .sort () #Sort the A list
25
+ return A #We return A
You can’t perform that action at this time.
0 commit comments