brewersfan1976

alphabet_sequence.rb

Apr 7th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.39 KB | None | 0 0
  1. def alphabetSubsequence(s)
  2.     array_length = s.length
  3.     x = 0
  4.     y = 1
  5.    
  6.     while (x < array_length)
  7.          while (y < array_length)
  8.              if s[x] == s[y] or s[y] <= s[x] then
  9.                 return false
  10.              end
  11.            
  12.              y = y + 1
  13.          end
  14.              
  15.          x = x + 1
  16.          y = x + 1
  17.     end
  18.        
  19.     return true
  20. end
Advertisement
Add Comment
Please, Sign In to add comment