-
-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathQuicksort1-Partition.java
More file actions
26 lines (24 loc) · 774 Bytes
/
Copy pathQuicksort1-Partition.java
File metadata and controls
26 lines (24 loc) · 774 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
import java.util.*;
public class Solution {
static void partition(int[] ar) {
int num = ar[0];
String s1 = "";
String s2 = "";
for(int i=1;i<ar.length;i++){
if(ar[i]<num)
s1 = s1 + ar[i] + " ";
else if(ar[i]>num)
s2 = s2 + ar[i] + " ";
}
System.out.println(s1 + num + " " + s2);
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] ar = new int[n];
for(int i=0;i<n;i++){
ar[i]=in.nextInt();
}
partition(ar);
}
}