def assert_equal(x, y) raise [x, y].inspect unless x == y end class Solution # time: O(n) # space: O(1) def self.run(items) max = nil hit = 0 for i in items if max.nil? max = i elsif i > max hit += 1 end max = i return false if hit > 1 end true end end assert_equal true, Solution.run([13, 4, 7]) assert_equal false, Solution.run([5,1,3,2,5]) puts 'Yay!'