Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'set'
- def cons_seq(arr)
- continious_sequence = 1
- all_cont_seq = Set.new
- arr.sort!.uniq!.each_with_index do |el, i|
- if el + 1 == arr[i + 1]
- continious_sequence += 1
- else
- all_cont_seq << continious_sequence
- continious_sequence = 1
- end
- end
- all_cont_seq.max
- end
- arr = [1,92,5,47,3,4,5,2,89,56,90,23,91,24,4,92]
- puts cons_seq(arr)
Advertisement
Add Comment
Please, Sign In to add comment