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.
vector<int>parseInts(stringstr){stringstreamss;ss<<str;//transfer string to stringstreamvector<int>result;// create a vector to hold the vector containing numberscharcharacter_stream_dump;// a variable to collect all the charactersintnumber_stream;// variable of type int to collect all the integer values while(ss>>number_stream)// as long as (dump numbers from ss in number_stream) holds true-- 2,5,7 becomes ,5,7 {result.push_back(number_stream);// add the collected number in vectorss>>character_stream_dump;// tranfer the stream of characters (,) to character_stream_dump, which means ,5,7 becomes 5,7 }returnresult;//returns final vector of numbers}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
StringStream
You are viewing a single comment's thread. Return to all comments →