Check my code someone

For which test case my code is not working right?

hey @Aparna, please share the code saved in coding blocks ide.

#include #include #include<string.h> using namespace std; int main() { int t,m; cin>>t; while(t!=0){ cin>>m; string arr[m]; for(int i=0;i<m;i++){ cin>>arr[i]; } string ans; for(int i=0;i<m;i++){ if(arr[i]>ans){ ans=arr[i]+ans; } else{ ans=ans+arr[i]; } } cout<<ans<<endl; t–; } }

1 Like

hey @Aparna, you appraoch is not correct, For this problem you can treat the array’s elements as strings and sort them in lexicographically decreasing order. For eg. [54, 546, 548, 60] if you sort these in lexicographically decreasing order taking them as string result will be [60, 548, 546, 54] , then you can print all the elements and it will form the biggest number.