Beta

Tall Tales

Description:

You're queued for lunch at the Hooli cafeteria, eagerly anticipating the special of the day: Organic, grass-fed, free-range chicken breast with a side of kale (mmm).

All of a sudden, the fire alarm goes off and you all race outside. Breathing a sigh of relief as you realize it was just a drill, you head back to the cafeteria. As an egalitarian, meritocratic future company (tm), you and your coworkers are committed to restoring the correct order of the line. Problem is, you don't remember your number in line.

What you DO know is how many people in front of you were at least as tall as you (f) and your own height (h) in centimeters.

So your properties will looks something like this, where both n and k are guaranteed to be nonnegative integers.

{
  h: 195,
  f: 3
}

Given a list of employees with such properties, find the correct ordering of the line. Any employee with f = x should be behind exactly x other employees.

// Given this
var unordered = [{h: 200, f: 1}, {h: 185, f: 2}, {h: 190, f: 0}, {h: 175, f: 4}, {h: 190, f: 2}, {h: 200, f: 0}]

// End up with this
var ordered = [{h: 190, f: 0}, {h: 200, f: 0}, {h: 185, f: 2}, {h: 190, f: 2}, {h: 175, f: 4}, {h: 200, f: 1}]
Algorithms

Stats:

CreatedOct 25, 2016
PublishedOct 25, 2016
Warriors Trained84
Total Skips36
Total Code Submissions141
Total Times Completed15
JavaScript Completions15
Total Stars6
% of votes with a positive feedback rating81% of 8
Total "Very Satisfied" Votes6
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes1
Total Rank Assessments7
Average Assessed Rank
5 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • nwkotto Avatar
Ad