diff --git a/problems/0977.有序数组的平方.md b/problems/0977.有序数组的平方.md index b10620d0..7119dda5 100644 --- a/problems/0977.有序数组的平方.md +++ b/problems/0977.有序数组的平方.md @@ -100,6 +100,18 @@ public: ## 其他语言版本 ### Java: +排序法 +```Java +class Solution { + public int[] sortedSquares(int[] nums) { + for (int i = 0; i < nums.length; i++) { + nums[i] = nums[i] * nums[i]; + } + Arrays.sort(nums); + return nums; + } +} +``` ```Java class Solution {