Skip to content

Commit 9978be7

Browse files
committed
977 - C++
1 parent 241e121 commit 9978be7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
bool check(int x, int y){
2+
return abs(x) < abs(y);
3+
}
4+
5+
class Solution {
6+
public:
7+
8+
vector<int> sortedSquares(vector<int>& A) {
9+
10+
sort(A.begin(), A.end(), check);
11+
12+
for(int i = 0; i < A.size(); i++)
13+
A[i] = pow(A[i], 2);
14+
15+
return A;
16+
}
17+
};

0 commit comments

Comments
 (0)