Ruby 1 line yet TLE...


  • 0
    L
    def max_rotate_function(a)
        (0...a.length).to_a.map.with_index{|x, i| x = a.rotate(-i).each_with_index.inject(0) {|sum, (j, e)| sum + j * e}}.max.to_i
    end
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.