632C. The Smallest String Concatenation - Codeforces Solution C++

  Problem Link : 632C. The Smallest String Concatenation 


✅ C++ Solution :

 
#include<bits/stdc++.h>
using namespace std;

#define ll long long int

bool comp(string x, string y)
{
	return x+y < y+x;
}

int main()
{
	int n;
	cin>>n;
	string arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];

	sort(arr,arr+n,comp);
	for(string s: arr)
		cout<<s;
}

 

Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook. 

😇Happy Learning!!