We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b43e1e0 commit 1eaf187Copy full SHA for 1eaf187
1790.仅执行一次字符串交换能否使两个字符串相等/solution.cpp
@@ -0,0 +1,13 @@
1
+class Solution {
2
+public:
3
+ bool areAlmostEqual(string s1, string s2) {
4
+ vector<int> vec;
5
+ int sz=s1.size();
6
+ for (int i=0;i<sz;i++) {
7
+ if (s1.at(i)!=s2.at(i)) {
8
+ vec.push_back(i);
9
+ }
10
11
+ return vec.size()==0 || (vec.size()==2 && s1.at(vec.at(0))==s2.at(vec.at(1)) && s1.at(vec.at(1))==s2.at(vec.at(0)));
12
13
+};
0 commit comments