You are viewing a single comment's thread. Return to all comments →
you can cheak this https://github.com/user23052036/Hacker_Rank git repo for all the Hacker Rank solution.
BEST OF LUCK
using namespace std;
int main() { int n,q; cin>>n>>q;
unordered_map<string,string>ump; vector<string>tags; string tag,value,val; char unwanted,equal; for(int i=0; i<n; i++) { int how_much; string str; getline(cin>>ws,str); stringstream ss(str); ss>>unwanted>>tag; if(tag.front() != '/' && tag.back() == '>') { tag.pop_back(); tags.push_back(tag); continue; } else if(tag[0] != '/') { tags.push_back(tag); do { string key; ss>>value>>equal>>val; (val.back() == '>')? how_much=3 : how_much=2; for(int i=0; i<tags.size(); i++) key += tags[i] + '.'; key.pop_back(); key = key + '~' + value; ump[key]=val.substr(1,val.size()-how_much); }while(val.back() != '>'); } else tags.pop_back(); } while(q--) { string quaries; getline(cin,quaries); if(ump.count(quaries) > 0) cout<<ump[quaries]<<"\n"; else cout<<"Not Found!"<<"\n"; } return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Attribute Parser
You are viewing a single comment's thread. Return to all comments →
you can cheak this https://github.com/user23052036/Hacker_Rank git repo for all the Hacker Rank solution.
BEST OF LUCK
include
using namespace std;
int main() { int n,q; cin>>n>>q;
}