925. 长按键入

it2025-04-10  19

class Solution { public: bool isLongPressedName(string name, string typed) { int i = 0, j = 0; while (j < typed.length()) { if ( name[i] == typed[j]) { i++; j++; } else if (j > 0 && typed[j] == typed[j - 1]) { j++; } else { return false; } } if(i == name.length()) return true; return false; } };

 

最新回复(0)