Ruby solution in 3 lines


  • 0
    T
    def reconstruct_queue(people)
      new_list = []
      people.sort_by {|a, b| [-a, b] }.each { |person| new_list.insert(person[1], person) }
      return new_list
    end
    

Log in to reply
 

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