We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Didn't know the useful str.swap(), ended up with the slightly more verbose:
#include<iostream>#include<string>usingnamespacestd;intmain(){// Complete the program stringa,b;cin>>a>>b;cout<<a.size()<<" "<<b.size()<<"\n"<<a+b<<"\n";cout<<b[0]+a.substr(1)<<" "<<a[0]+b.substr(1);return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Strings
You are viewing a single comment's thread. Return to all comments →
Didn't know the useful str.swap(), ended up with the slightly more verbose: