brewersfan1976

are_isomorphic.rb

Oct 15th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.51 KB | None | 0 0
  1. def areIsomorphic(array1, array2)
  2.     if array1.length != array2.length then
  3.        return false
  4.     end
  5.        
  6.     output1 = Array.new
  7.     output2 = Array.new
  8.     x = 0
  9.        
  10.     while (x < array1.length)
  11.           output1[x] = array1[x].length
  12.           x = x + 1
  13.     end
  14.        
  15.     x = 0
  16.        
  17.     while (x < array2.length)
  18.           output2[x] = array2[x].length
  19.           x = x + 1
  20.     end
  21.    
  22.     if output1 != output2 then
  23.        return false
  24.     end
  25.        
  26.     return true
  27. end
Advertisement
Add Comment
Please, Sign In to add comment