Created
February 27, 2017 17:59
-
-
Save devteampentagon/c018b059e9bb1bb5c79af9ad434ff13c to your computer and use it in GitHub Desktop.
Number Sorting upto 10 to the power 6 digits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Author: Emrul Chowdhury | |
#include <bits/stdc++.h> | |
#define LL long long int | |
using namespace std; | |
map <LL, LL> mp; | |
vector <string> v[2000005]; | |
vector <LL> v1; | |
int main() | |
{ | |
string s; | |
LL n,i ; | |
cin >> n; | |
for( i=0; i<n; i++ ) | |
{ | |
cin >> s; | |
if( mp[s.size()] == 0 ) | |
{ | |
v1.push_back(s.size()); | |
} | |
mp[ s.size() ]++; | |
v[ s.size() ].push_back(s); | |
} | |
sort( v1.begin(), v1.end() ); | |
for( i=0; i<v1.size(); i++ ) | |
{ | |
sort( v[v1[i]].begin(), v[v1[i]].end() ); | |
for( LL j=0; j<v[v1[i]].size(); j++ ) | |
{ | |
cout << v[v1[i]][j] << endl; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment