双指针 - 长按键入
生活随笔
收集整理的這篇文章主要介紹了
双指针 - 长按键入
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目鏈接
class Solution { public:bool isLongPressedName(string name, string typed) {int n1 = name.size();int n2 = typed.size();int i = 0, j = 0;while (j < n2) {if (i < n1 && name[i] == typed[j]) {++i;++j;}else if (i > 0 && name[i-1] == typed[j]) {++j;}else {cout << i << " " << j << endl;return false; }}return i == n1;} };總結
以上是生活随笔為你收集整理的双指针 - 长按键入的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: LeetCode每日一题 143. 重排
- 下一篇: 贪心 - 划分字母区间