File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 356
356
| 1389 | [ Create Target Array in Given Order] ( https://leetcode.com/problems/create-target-array-in-the-given-order ) | | |
357
357
| 1394 | [ Find Lucky Integer In An Array] ( https://leetcode.com/problems/find-lucky-integer-in-an-array ) | | |
358
358
| 1399 | [ Count Largest Group] ( https://leetcode.com/problems/count-largest-group ) | | |
359
- | 1403 | [ Minimum Subsequence in Non-Increasing Order] ( https://leetcode.com/problems/minimum-subsequence-in-non-increasing-order ) | | |
359
+ | 1403 | [ Minimum Subsequence in Non-Increasing Order] ( https://leetcode.com/problems/minimum-subsequence-in-non-increasing-order ) | [ ![ Java ] ( assets/java.png )] ( src/CreateTargetArrayInGivenOrder.java ) | |
360
360
| 1408 | [ String Matching In An Array] ( https://leetcode.com/problems/string-matching-in-an-array ) | | |
361
361
| 1413 | [ Minimum Value To Get Positive Step By Step Sum] ( https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum ) | | |
362
362
| 1417 | [ Reformat The String] ( https://leetcode.com/problems/reformat-the-string ) | | |
Original file line number Diff line number Diff line change
1
+ import java .util .ArrayList ;
2
+ import java .util .List ;
3
+
4
+ public class CreateTargetArrayInGivenOrder {
5
+ public int [] createTargetArray (int [] nums , int [] index ) {
6
+ List <Integer > result = new ArrayList <>();
7
+ for (int i = 0 ; i < index .length ; i ++) {
8
+ result .add (index [i ], nums [i ]);
9
+ }
10
+ return toArray (result );
11
+ }
12
+
13
+ private int [] toArray (List <Integer > list ) {
14
+ int [] array = new int [list .size ()];
15
+ for (int index = 0 ; index < array .length ; index ++) {
16
+ array [index ] = list .get (index );
17
+ }
18
+ return array ;
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments