Ruby 100% beats


  • 0
    Q
    def reconstruct_queue(people)
        people.sort!{ |x,y| x[0] == y[0] ? x[1] <=> y[1] : y[0] <=> x[0] }
        list = []
        people.size.times { |i| list.insert(people[i][1],people[i]) }
        list
    end
    

Log in to reply
 

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