rs: add «977. Squares of a Sorted Array»
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
8d4fc53789
commit
668057d19c
1 changed files with 10 additions and 0 deletions
10
rs/squares-of-a-sorted-array.rs
Normal file
10
rs/squares-of-a-sorted-array.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
impl Solution {
|
||||
pub fn sorted_squares(mut nums: Vec<i32>) -> Vec<i32> {
|
||||
for x in &mut nums {
|
||||
*x *= *x;
|
||||
}
|
||||
nums.sort_unstable();
|
||||
|
||||
nums
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue