-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathjs.js
More file actions
37 lines (32 loc) · 672 Bytes
/
js.js
File metadata and controls
37 lines (32 loc) · 672 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
/**
* @param {string} s1
* @param {string} s2
* @return {boolean}
*/
var canBeEqual = function (s1, s2) {
if (s1 === s2) return true
let copy
let temp
copy = s1.split('')
temp = copy[0]
copy[0] = copy[2]
copy[2] = temp
console.log(copy.join(''))
if (copy.join('') === s2) return true
copy = s1.split('')
temp = copy[1]
copy[1] = copy[3]
copy[3] = temp
console.log(copy.join(''))
if (copy.join('') === s2) return true
copy = s1.split('')
temp = copy[0]
copy[0] = copy[2]
copy[2] = temp
temp = copy[1]
copy[1] = copy[3]
copy[3] = temp
console.log(copy.join(''))
if (copy.join('') === s2) return true
return false
}