2490.cpp (335B)
1 class Solution { 2 public: 3 bool isCircularSentence(const string &sentence) const { 4 char prev = sentence.back(); 5 stringstream ss(sentence); 6 string word; 7 8 while (ss >> word) { 9 if (word.front() != prev) return false; 10 prev = word.back(); 11 } 12 13 return true; 14 } 15 };