Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def areSimilar(a, b)
- if a == b then
- return true
- end
- array = Array.new
- i = 0
- while (i < a.length)
- if a[i] != b[i] then
- array.push(i)
- end
- i = i + 1
- end
- if array.length == 0 then
- return true
- end
- if array.length != 2 then
- return false
- end
- id1 = array[0]
- id2 = array[1]
- if a[id1] == b[id2] and a[id2] == b[id1] then
- return true
- end
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment