-
Notifications
You must be signed in to change notification settings - Fork 160
/
buddy-strings.md
58 lines (44 loc) · 1.83 KB
/
buddy-strings.md
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
<p>Given two strings <code>A</code> and <code>B</code> of lowercase letters, return <code>true</code> if and only if we can swap two letters in <code>A</code> so that the result equals <code>B</code>.</p>
<p> </p>
<p><strong>Example 1:</strong></p>
<div>
<pre>
<strong>Input: </strong>A = <span id="example-input-1-1">"ab"</span>, B = <span id="example-input-1-2">"ba"</span>
<strong>Output: </strong><span id="example-output-1">true</span>
</pre>
<div>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input: </strong>A = <span id="example-input-2-1">"ab"</span>, B = <span id="example-input-2-2">"ab"</span>
<strong>Output: </strong><span id="example-output-2">false</span>
</pre>
<div>
<p><strong>Example 3:</strong></p>
<pre>
<strong>Input: </strong>A = <span id="example-input-3-1">"aa"</span>, B = <span id="example-input-3-2">"aa"</span>
<strong>Output: </strong><span id="example-output-3">true</span>
</pre>
<div>
<p><strong>Example 4:</strong></p>
<pre>
<strong>Input: </strong>A = <span id="example-input-4-1">"aaaaaaabc"</span>, B = <span id="example-input-4-2">"aaaaaaacb"</span>
<strong>Output: </strong><span id="example-output-4">true</span>
</pre>
<div>
<p><strong>Example 5:</strong></p>
<pre>
<strong>Input: </strong>A = <span id="example-input-5-1">""</span>, B = <span id="example-input-5-2">"aa"</span>
<strong>Output: </strong><span id="example-output-5">false</span>
</pre>
<p> </p>
<p><strong><span>Note:</span></strong></p>
<ol>
<li><code>0 <= A.length <= 20000</code></li>
<li><code>0 <= B.length <= 20000</code></li>
<li><code>A</code> and <code>B</code> consist only of lowercase letters.</li>
</ol>
</div>
</div>
</div>
</div>
</div>