Skip to content

Commit dd3a805

Browse files
Update ReduceArray.java
1 parent c295d58 commit dd3a805

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

ApplyingCollections/ReduceArray.java

+21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
/*There is an array of N elements. Perform the following operation until there are only two elements left in the array.
2+
Input format
3+
There are two lines of input.
24
5+
First line contains N, the number of elements.
6+
7+
Second line contains N space separated integers.
8+
9+
Output format
10+
Print the last element left in the array.
11+
12+
Sample Input 1
13+
5
14+
15+
2 1 11 13 7
16+
17+
Sample Output 1
18+
2
19+
20+
Constraints
21+
1 <= N <= 10^5
22+
23+
1 <= A[i] <= 10^9
324
Remove the largest and second largest element from the array and insert their absolute difference back in the array.
425
*/
526

0 commit comments

Comments
 (0)