Turbo Sort Codechef Solution

Hello coders, today we are going to solve Turbo Sort Codechef Solution. Which is a part of Codechef Solution.

Turbo Sort Codechef Solution
Turbo Sort Codechef Solution

Problem

Given the list of numbers, you are to sort them in non decreasing order.

Input

t – the number of numbers in list, then t lines follow [t <= 10^6].

Each line contains one integer: N [0 <= N <= 10^6]

Output

Output given numbers in non decreasing order.

Example

Input:

5
5
3
6
7
1

Output:

1
3
5
6
7

Turbo Sort CodeChef Solution in Python

N = int(input())
l = []
for N in range(N):
    l.append(int(input()))
Result = sorted(l)
for R in Result:
    print(R)   

Turbo Sort CodeChef Solution in CPP

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t ;
    cin >> t;
    vector<int>v;
    while(t--){
    int n;
    cin >> n;
    v.push_back(n);
    }
    sort(v.begin(),v.end());
    for(int x=0;x<v.size();x++)
        cout << v[x] << '\n';
    }

Turbo Sort CodeChef Solution in JAVA

import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)
         a[i]=sc.nextInt();
        Arrays.sort(a);
        for(int i=0;i<n;i++)
         System.out.println(a[i]);
    }
}

Disclaimer: The above Problem (Turbo Sort) is generated by CodeChef but the solution is provided by Chase2learn.This tutorial is only for Educational and Learning purpose.

Sharing Is Caring

Leave a Comment