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.
#include<bits/stdc++.h>#include<string>usingnamespacestd;/* * Complete the 'superReducedString' function below. * * The function is expected to return a STRING. * The function accepts STRING s as parameter. */stringsuperReducedString(strings){for(inti=1;i<s.length();i++){if(s[i]==s[i-1]){s.erase(s.begin()+i);s.erase((s.begin()+(i-1)));i=1;}if(s.length()==0){return"Empty String";}}if(s[0]==s[1]){return"Empty String";}returns;}intmain(){ofstreamfout(getenv("OUTPUT_PATH"));strings;getline(cin,s);stringresult=superReducedString(s);fout<<result<<"\n";fout.close();return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Super Reduced String
You are viewing a single comment's thread. Return to all comments →