Skip to content

Commit adfb14d

Browse files
add 3069
1 parent a9b314e commit adfb14d

File tree

2 files changed

+32
-0
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src/main/java/com/fishercoder/solutions/fourththousand

2 files changed

+32
-0
lines changed

Diff for: paginated_contents/algorithms/4th_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
| 3083 | [Existence of a Substring in a String and Its Reverse](https://leetcode.com/problems/existence-of-a-substring-in-a-string-and-its-reverse/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3083.java) | | Easy |
5555
| 3079 | [Find the Sum of Encrypted Integers](https://leetcode.com/problems/find-the-sum-of-encrypted-integers/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3079.java) | | Easy |
5656
| 3074 | [Apple Redistribution into Boxes](https://leetcode.com/problems/apple-redistribution-into-boxes/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3074.java) | | Easy |
57+
| 3069 | [Distribute Elements Into Two Arrays I](https://leetcode.com/problems/distribute-elements-into-two-arrays-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3069.java) | | Easy |
5758
| 3062 | [Winner of the Linked List Game](https://leetcode.com/problems/winner-of-the-linked-list-game/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3062.java) | | Easy |
5859
| 3046 | [Split the Array](https://leetcode.com/problems/split-the-array/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3046.java) | | Easy |
5960
| 3042 | [Count Prefix and Suffix Pairs I](https://leetcode.com/problems/count-prefix-and-suffix-pairs-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3042.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class _3069 {
7+
public static class Solution1 {
8+
public int[] resultArray(int[] nums) {
9+
int[] ans = new int[nums.length];
10+
List<Integer> list1 = new ArrayList<>();
11+
list1.add(nums[0]);
12+
List<Integer> list2 = new ArrayList<>();
13+
list2.add(nums[1]);
14+
for (int i = 2; i < nums.length; i++) {
15+
if (list1.get(list1.size() - 1) > list2.get(list2.size() - 1)) {
16+
list1.add(nums[i]);
17+
} else {
18+
list2.add(nums[i]);
19+
}
20+
}
21+
int i = 0;
22+
for (int j = 0; j < list1.size(); j++) {
23+
ans[i++] = list1.get(j);
24+
}
25+
for (int j = 0; j < list2.size(); j++) {
26+
ans[i++] = list2.get(j);
27+
}
28+
return ans;
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)