-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathArrayInput.java
More file actions
33 lines (28 loc) Β· 770 Bytes
/
Copy pathArrayInput.java
File metadata and controls
33 lines (28 loc) Β· 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package day4;
import java.util.Scanner;
public class ArrayInput {
/*
n = array.length
time complexity: O(n)
space complexity: O(n)
*/
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int length = scanner.nextInt();
int[] array = new int[length];
for (int index = 0 ; index < array.length ; index++) {
array[index] = scanner.nextInt();
}
print(array);
}
/*
n = array.length
time complexity: O(n)
space complexity: O(1)
*/
private static void print(int[] array) {
for (int index = 0 ; index < array.length ; index++) {
System.out.print(array[index] + " ");
}
}
}