which test case isn’t covered?
Test case failing
hi… pls share ur code… only then will I be able to check…
#include<bits/stdc++.h> using namespace std; bool cmp(string a,string b){ if((a.size()<=b.size()) && (b.substr(0,a.size() )==a )){ return false; }else if((b.size()<=a.size()) && (a.substr(0,b.size())==b)){ return true; }else return a<b; } int main() { string s[100]; int t; cin>>t; if(t<0){ return 0; } for(int i=0;i<t;i++){ cin>>s[i]; } sort(s,s+t,cmp); for(int i=0;i<t;i++){ cout<<s[i]<<endl; } return 0; }
hi… when u share ur code pls save it on ide and send… otherwise it becomes very difficult to check code… for now u can refer my code https://ide.codingblocks.com/s/605306
your code is also failing for Test case 1… pls check
ok… let me check ur code with some sample tests
thanks, appreciated.
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.
still didn’t get clarification on what went wrong on my code
oh… okay… i thought its clear… wait will check.
]what u are doing wrong is simply checking on basis of length…
in actual u have to check character by character till min(s1.size(), s2.size())
and then checking length part
ig now ur doubts would be cleared??
yeah got it, thanks…
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.
