Advertisement
brewersfan1976

different_substring_trie.rb

Dec 27th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.55 KB | None | 0 0
  1. def differentSubstringsTrie(inputString)
  2.     unique_characters = inputString.split(//).uniq.length
  3.     array = Array.new
  4.     x = 0
  5.     y = 1
  6.     z = 0
  7.    
  8.     while (x < inputString.length - 1)
  9.           string = inputString[x]
  10.        
  11.           while (y < inputString.length)
  12.                 string = string + inputString[y]
  13.                 array[z] = string
  14.                 y = y + 1
  15.                 z = z + 1
  16.           end
  17.        
  18.           x = x + 1
  19.           y = x + 1
  20.     end
  21.    
  22.     return unique_characters + array.uniq.length
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement