forked from luliyucoordinate/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0925.cpp
More file actions
28 lines (26 loc) · 683 Bytes
/
0925.cpp
File metadata and controls
28 lines (26 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
static int x = []() {std::ios::sync_with_stdio(false); cin.tie(0); return 0; }();
class Solution
{
public:
bool isLongPressedName(string name, string typed)
{
int i = 0, m = name.length(), n = typed.length();
for (unsigned int j = 0; j < n; ++j)
if (i < m and name[i] == typed[j])
++i;
else if (j == 0 or typed[j] != typed[j - 1])
return false;
return i == m;
}
};
int main()
{
string name = "alex";
string typed = "aaleex";
cout << Solution().isLongPressedName(name, typed);
return 0;
}