-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday32.cpp
More file actions
40 lines (35 loc) · 899 Bytes
/
day32.cpp
File metadata and controls
40 lines (35 loc) · 899 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
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// Function to check if s is a subsequence of t
bool isSubsequence(const string& s, const string& t) {
string::size_type i = 0, j = 0; // Use std::string::size_type for indices
while (i < s.length() && j < t.length()) {
if (s[i] == t[j]) {
i++;
}
j++;
}
return i == s.length();
}
int main() {
int T;
cin >> T;
cin.ignore(); // Ignore newline character after reading T
vector<string> results;
for (int test = 0; test < T; ++test) {
string s, t;
getline(cin, s);
getline(cin, t);
if (isSubsequence(s, t)) {
results.push_back("true");
} else {
results.push_back("false");
}
}
for (const string& result : results) {
cout << result << endl;
}
return 0;
}