1class Solution {2 public:3 int countSegments(string s) {4 if (s == "") return 0;5 int res = 0, flag = 0;6 for (int i = 0; i < size(s); i++) {7 if (s[i] != ' ') {8 i++;9 while (i < size(s) and s[i] != ' ') {10 i++;11 }12 res++;13 }14 }15 return res;16 }17};
WPM •0 •0
ACC •0 •0
TIME •0