Skip to content

Commit 228e72c

Browse files
add 912
1 parent e95ff09 commit 228e72c

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Your ideas/fixes/algorithms are more than welcome!
7272
|922|[Sort Array By Parity II](https://leetcode.com/problems/sort-array-by-parity-ii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_922.java) | O(n) | O(1) | |Easy|
7373
|917|[Reverse Only Letters](https://leetcode.com/problems/reverse-only-letters/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_917.java) | O(n) | O(n) | |Easy|
7474
|914|[X of a Kind in a Deck of Cards](https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_914.java) | O(n) | O(n) | |Easy|
75+
|912|[Sort an Array](https://leetcode.com/problems/sort-an-array/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_912.java) | O(nlogn) | O(1) | |Easy|
7576
|908|[Smallest Range I](https://leetcode.com/problems/smallest-range-i/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_908.java) | O(n) | O(1) | |Easy|
7677
|900|[RLE Iterator](https://leetcode.com/problems/rle-iterator/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_900.java) | O(n) | O(1) | |Medium|
7778
|897|[Increasing Order Search Tree](https://leetcode.com/problems/increasing-order-search-tree/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_897.java) | O(n) | O(n) | |Easy| DFS, recursion
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.fishercoder.solutions;
2+
3+
import java.util.Arrays;
4+
5+
/**
6+
* 912. Sort an Array
7+
*
8+
* Given an array of integers nums, sort the array in ascending order.
9+
*
10+
* Example 1:
11+
*
12+
* Input: [5,2,3,1]
13+
* Output: [1,2,3,5]
14+
* Example 2:
15+
*
16+
* Input: [5,1,1,2,0,0]
17+
* Output: [0,0,1,1,2,5]
18+
*
19+
*
20+
* Note:
21+
*
22+
* 1 <= A.length <= 10000
23+
* -50000 <= A[i] <= 50000
24+
* */
25+
public class _912 {
26+
public static class Solution1 {
27+
public int[] sortArray(int[] nums) {
28+
Arrays.sort(nums);
29+
return nums;
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)