# Easy - Peasy (Contest)

Problem Statement :&#x20;

Given an array of length N in which you can swap two elements if their sum is odd i.e for every i (1 to N) and j (1 to N) if (Arr\[i] + Arr\[j]) is odd then you can swap these elements. What is the lexicographically smallest array you can obtain? Input First line of input contains a single integer N. Next line contains N space separated integers depicting the elements of the array.

Constraints:- 1 <= N <= 100000 1 <= Arr\[i] <= 100000 Output Print N space separated elements i. e the array which is the lexicographically smallest possible Example Sample Input:- 3 4 1 7

Sample Output:- 1 4 7

Explanation:- Swap 1 and 2 as their sum 4 + 1 = 5 is odd

Sample Input:- 2 2 4

Sample Output:- 2 4

Sample Input:- 2 5 3

Sample Output:- 5 3

link:<https://my.newtonschool.co/playground/code/wbb491jaf8im>

```java
import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework

// don't change the name of this class
// you can add inner classes if needed
class Main {
    static void smaller(int arr[], int n){
        int odd=0;
        int even=0;
        for(int i=0;i<n;i++){
            if(arr[i]%2==1)
            odd++;
            else
            even++;
        }
        if(odd>0 && even>0)
        Arrays.sort(arr);
        for(int i=0;i<n;i++){
            System.out.print(arr[i]+" ");
        }
    }
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        smaller(arr,n);

    }
}
 
 
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://anand-aryan.gitbook.io/placecom-question/easy-peasy-contest.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
