Error
|
|
---|---|
@Ibrahim Nash | 5761 |
@blackshadows | 5701 |
@akhayrutdinov | 5111 |
@mb1973 | 4989 |
@Quandray | 4944 |
@saiujwal13083 | 4506 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3516 |
@sushant_a | 3459 |
@verma_ji | 3341 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@aroranayan999 | 938 |
@bt8816103042 | 739 |
@SHOAIBVIJAPURE | 428 |
@codeantik | 412 |
@SherlockHolmes3 | 407 |
@neverevergiveup | 348 |
@mahlawatep | 347 |
@shalinibhataniya1097 | 343 |
@murarry3625 | 333 |
@saiujwal13083 | 326 |
@rohitanand | 314 |
Complete Leaderboard |
Given an unsorted array arr of size N, rearrange the elements of array such that number at the odd index is greater than the number at the previous even index. The task is to complete the function formatArray() which will return formatted array.
Input:
The first line of input contains T, denoting the number of testcases. First line of every test case consists of N, denoting number of elements in an array. Second line of every testcase consists of elements in an array separated by space.
Output:
If the array formed is according to rules print 1, else 0.
User task:
Since this is a functional problem you don't have to worry about the input, you just have to complete the function formatArray(), which accepts array arr and its size
Constraints:
1 <= T <= 100
1 <= N <= 100
1 <= arr[i] <= 100
Example:
Input:
2
5
5 4 3 2 1
4
4 3 2 1
Output:
1
1
Explanation:
Testcase 1: The given array after modification will be as such: 4 5 2 3 1.
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes