-
Notifications
You must be signed in to change notification settings - Fork 0
/
Check_if_two_strings_Arrays_Are_equivalent.cpp
68 lines (68 loc) · 1.66 KB
/
Check_if_two_strings_Arrays_Are_equivalent.cpp
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<<<<<<< HEAD
class Solution
{
public:
bool arrayStringsAreEqual(vector<string> &word1, vector<string> &word2)
{
std::string str1;
for (const auto &word : word1)
{
str1 += word;
}
std::string str2;
for (const auto &word : word2)
{
str2 += word;
}
return str1 == str2;
}
int main()
{
std::vector<std::string> word1 = {"ab", "c"};
std::vector<std::string> word2 = {"a", "bc"};
bool result = arrayStringsAreEqual(word1, word2);
if (result)
{
std::cout << "The two arrays represent the same string.\n";
}
else
{
std::cout << "The two arrays do not represent the same string.\n";
}
return 0;
}
=======
class Solution
{
public:
bool arrayStringsAreEqual(vector<string> &word1, vector<string> &word2)
{
std::string str1;
for (const auto &word : word1)
{
str1 += word;
}
std::string str2;
for (const auto &word : word2)
{
str2 += word;
}
return str1 == str2;
}
int main()
{
std::vector<std::string> word1 = {"ab", "c"};
std::vector<std::string> word2 = {"a", "bc"};
bool result = arrayStringsAreEqual(word1, word2);
if (result)
{
std::cout << "The two arrays represent the same string.\n";
}
else
{
std::cout << "The two arrays do not represent the same string.\n";
}
return 0;
}
>>>>>>> 3a9d63e5f730caf996f177773888a27003be2394
};