How to approch to this problem

hey please tell me how to approch to this problem using character array

hi @mahroosanwar0901_2642b14836027bbf


Refer this… here I have used string… just replace it with character array… logic remains the same…

Thanks it’s working fine

1 Like

can I ask anothrer question from array , I have already ask but that TA not give response

sure @mahroosanwar0901_2642b14836027bbf
raise a doubt under that particular ques, i will pick ur doubt…

mark as resolve not working from my side for that question

so how to raid doubt from there , i am already in doubt session

well i have raised if you find

oh u have doubt in this ques only??

kartik bhaiya and strind i solved and understand but
que( Form biggest number) well my que is that as i use char array in above question because i have use char array because we dealing with single char. but how can I do ( form biggest num ) if i am dealing with
a number ( more than one char) using charr array

u can use strings in that ques…
refer this -->

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

bool myCompare(string X,string Y){
	string XY = X.append(Y);
	string YX = Y.append(X);

	return XY.compare(YX) > 0 ? 1: 0; 
}

int main() {
	int t;
	cin>>t;
	while(t--){
		int n;
		string no;
		cin>>n;
		vector<string> v;
		for(int i=0;i<n;i++){
			cin>>no;
			v.push_back(no);
		}
		sort(v.begin(),v.end(),myCompare);
		for(int i=0;i<n;i++){
			cout<<v[i];
		}
		cout<<endl;
	}
	return 0;
}

ya string part i got it but I want to use char array it that possible?
because that ques. is given in character array challenges and we haven’t learn yet string ( I know that just little bit different ) and vector too so there might be a method ?

i dont think that would be possible, bcoz we have to compare the concated strings as well in comparator function…

okay thanks you can mark it as resloved

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.