All submissions for this problem are available.
You’re given an array ar and a number p. Partition the array, so that all elements greater than p are to its right, and all elements smaller than p are to its left. p is called the pivot of the partition.
Guideline - in this problem, you do not need to move around the numbers ‘in-place’. This means you can create two lists and combine them at the end.
You will be given an array of integers. The number p is the first element in ar.There are two lines of input:
- n – the number of elements in the array ar
- the n elements of ar (including p at the beginning)
Print out the numbers of the partitioned array on the line
- 1 ≤ n ≤ 1000
- -1000 ≤ x ≤ 1000, x ∈ ar
- All elements will be unique
- Multiple answer can exists for a given test case. Print any one of them
Input: 5 88 22 77 33 11 Output: 11 22 33 77 88
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, RUBY, PHP, LISP sbcl, LISP clisp, SCM guile, PYP3|
Fetching successful submissions
If you are still having problems, see a sample solution here.