class Solution {
public:
int countSegments(string s) {
int count = 0 ;
int len = s.size();
for(int i = 0 ; i < len ; i++ ){
if(s[i] == ' '){
continue;
}
count++;
while(i<len && s[i] !=' ') i++;
}
return count;
}
};
434. Number of Segments in a String
最新推荐文章于 2019-09-15 10:03:37 发布