We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5db5e23 commit d418f24Copy full SHA for d418f24
3467.Transform-Array-by-Parity.java
@@ -0,0 +1,28 @@
1
+// https://leetcode.com/problems/transform-array-by-parity/description/
2
+// algorithms
3
+// Easy (88.4%)
4
+// Total Accepted: 32.3K
5
+// Total Submissions: 36.6K
6
+
7
8
+class Solution {
9
10
+ public int[] transformArray(int[] nums) {
11
+ int len = nums.length;
12
+ int evenNum = 0;
13
14
+ for (int n : nums) {
15
+ if ((n & 1) == 0) {
16
+ evenNum += 1;
17
+ }
18
19
20
+ int[] res = new int[len];
21
+ for (int i = evenNum; i < len; i++) {
22
+ res[i] = 1;
23
24
25
+ return res;
26
27
28
+}
0 commit comments