Turbo Sort | CodeChef Solution

Today we will be solving Turbo Sort CodeChef problem in Python, Java and C++ whose Code is TSORT.

turbo-sort-codechef-solution-codebrosindia

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

Solution – Turbo Sort CodeChef Solution

Python

#Solution Provided by SLoth Coders 
N = int(input())
l = []
for N in range(N):
    l.append(int(input()))
Result = sorted(l)
for R in Result:
    print(R)    

Java

/* package codechef; // don't place package name! */

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]);
	}
}
Turbo Sort Codechef Solution CodingBroz

C++

#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 CodingBroz

Disclaimer: The above problem (Turbo Sort : TSORT) is generated by CodeChef but the solution is provided by CodingBroz. This tutorial is only for Educational and Learning Purposes.

Broz Who Code

CodingBroz

Leave a Comment

Your email address will not be published. Required fields are marked *