Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #codality24 Dominator
- a = [3, 4, 3, 2, 3, -1, 3, 3]
- def solution(a)
- b = []
- count = a.count
- b = a.sort
- dominator = b[a.count/2]
- diarray = []
- for i in 0..(count-1)
- if a[i] == dominator
- diarray = diarray.push(i)
- else
- end
- end
- return diarray
- end
- puts "domonator array is #{solution(a)}"
Add Comment
Please, Sign In to add comment