class Solution {
public:
int compareVersion(string version1, string version2) {
for(int i = 0;i<version1.size();i++)
{
if(version1[i] == '.') version1[i] = ' ';
}
for(int i = 0;i<version2.size();i++)
{
if(version2[i] == '.') version2[i] = ' ';
}
vector<int>ans1,ans2;
int tmp;
stringstream ss1(version1),ss2(version2);
while(ss1>>tmp) ans1.push_back(tmp);
while(ss2>>tmp) ans2.push_back(tmp);
int i = 0;
int t1,t2;
while(i<ans1.size() || i<ans2.size())
{
t1 = i<ans1.size() ? ans1[i] : 0;
t2 = i<ans2.size() ? ans2[i] : 0;
if(t1<t2) return -1;
else if(t1>t2) return 1;
i++;
}
return 0;
}
};