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.
intmain(){stringn_temp;getline(cin,n_temp);intn=stoi(ltrim(rtrim(n_temp)));// Write your code hereunordered_map<int,string>mp={{1,"one"},{2,"two"},{3,"three"},{4,"four"},{5,"five"},{6,"six"},{7,"seven"},{8,"eight"},{9,"nine"}};if(mp.count(n))cout<<mp[n];elsecout<<"Greater than 9";return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Conditional Statements
You are viewing a single comment's thread. Return to all comments →
Create a hash table to solve the problem.