Problem : https://www.hackerrank.com/challenges/c-tutorial-stringstream/problem
Solution :
#include <sstream>
#include <vector>
#include <iostream>
using namespace std;
vector<int> parseInts(string str) {
// Complete this function
vector<int>v;
stringstream s(str);
int i;
char c;
while(s >> i){
v.push_back(i);
s>>c;
}
return v;
}
int main() {
string str;
cin >> str;
vector<int> integers = parseInts(str);
for(int i = 0; i < integers.size(); i++) {
cout << integers[i] << "\n";
}
return 0;
}