Ruby 4 lines


  • 0
    L
    def reconstruct_queue(people)
        people.sort_by!{|p| [-p[0], p[1]]}
        ret = []
        people.each{|p| ret.insert(p[1], p)}
        return ret
    end
    

Log in to reply
 

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