InterviewLegend

The HackerRank Screen

Alex Chen36 min readGuide updated 309 real interview reports
In this lesson
  • Know what the screen is worth: 50 minutes, two questions, a reported 120 marks, 60 to advance
  • Spend the clock where the marks are, since the grid question carries 70 to 75 of them on its own
  • Solve the maze with breadth-first search over moves, generating neighbours in one outward walk per direction
  • Clear the lighter half cleanly, where validation rather than algorithm choice is what costs marks

Wayfair's first technical step is a HackerRank test, sent as a link with a window to take it in. You get 50 minutes for two problems. The paper is usually 120 marks, roughly 70 or 75 on the first question and 50 on the second, and you need 60 to advance. Some sittings state the pass mark as a percentage instead, 60 percent in one account and 50 percent in another, and one candidate was told 75 marks. Whichever applies, the light question alone leaves you short, so the heavy one decides the result.

Partial credit is normal. One candidate passed 6 of 15 cases on the maze after using depth-first search and hitting a timeout, and another passed 8 of 13. Read both prompts before you type, start on the one worth 70, and get a correct answer in before you spend time making it fast. A working solution that times out on the biggest grids still keeps most of its cases.

What the screen is worth

The two slots on the paper behave differently. Since late 2023 the first has carried the same maze, a grid of empty cells and obstacles with a jump parameter added. It is worth 70 or 75 marks depending on the sitting.

Slot two rotates. IP zone classification and the task-scheduling question turn up most often. Sometimes the maze comes paired with a Premium question instead, which the arrays lesson works end to end. Other times the maze gives way to the minimum-cores sweep, and every problem below has turned up on a real screen.

The mark split has a practical consequence. The lighter question is cheap in time as well as in marks, since IP classification is twenty minutes of careful parsing and nothing more. Finish it, bank it, then give the rest of the hour to the grid. Leaving it to the end puts the easy marks behind the hard ones, which is the wrong order when time is short.

The grid question carries 70 to 75 of 120 marks, and the reported pass mark is 60. If you solve the light question perfectly and leave the grid blank, you score 50. So any plan for this screen has to end with working code on the grid. Code that times out on the largest cases still earns its passing cases, and those count toward the 60.

Two techniques cover the paper

Every problem below turns into a linear sweep once you settle what you are sweeping over. The grid question sweeps cells in breadth-first order; the two scheduling questions sweep a sorted list inward from its ends. Both sweeps are short. Most of the work is in the neighbour generator and the sort order.

One outward walk per direction

A jump of one cell and a jump of k cells cost the same single move, so the grid is an unweighted graph and breadth-first search finds the shortest route through it. The part worth drilling is how you list a cell's neighbours. One direction at a time, take cells outward from the current square and end the run at the grid edge or at the first obstacle. Every empty cell in that run is itself a legal landing spot, so record each one as it comes up.

python
def neighbours(maze, k, i, j):
n, m = len(maze), len(maze[0])
out = []
for di, dj in ((1, 0), (-1, 0), (0, 1), (0, -1)):
r, c = i, j
for _ in range(k): # one walk per direction, not k walks
r += di
c += dj
if r < 0 or r >= n or c < 0 or c >= m or maze[r][c] == 1:
break # an obstacle closes this direction entirely
out.append((r, c)) # every cell crossed is a landing spot
return out

That walk costs k inspections per direction. Generating the same neighbours as k separate jumps, each re-checking the whole span it covers, costs k squared instead. On a 100 by 100 grid with k of 100, that gap shows up as a timeout.

Sort inside the group, sweep from both ends

The scheduling pair are sorted sweeps. In the task question the sort happens inside each type bucket. The sweep then tries the lightest remaining task against the heaviest. That heavy task occupies a slot whatever happens, and the lightest is the only companion that might fit beside it. In the cores question the two boundary arrays are sorted apart from each other and walked together, counting how many processes are alive at once.

python
def units_for_group(memory_list, cap):
memory_list.sort()
light, heavy = 0, len(memory_list) - 1
units = 0
while light <= heavy: # <= so an odd group charges its middle task
# The heaviest task occupies this unit either way. Send the lightest
# along with it when the pair fits, and equality does fit.
if light < heavy and memory_list[light] + memory_list[heavy] <= cap:
light += 1
heavy -= 1
units += 1
return units

Two details in that loop matter. The condition is light <= heavy, so a bucket holding an odd number of tasks charges its middle task a unit of its own rather than dropping it. And the cap comparison is <=, because the sample in the prompt pairs two tasks whose memory sums to exactly the cap and still expects them to run together.

Both halves of the paper are scored on hidden cases, and those cases test the prompt's small print. An invalid address sits inside the IP question's own visible sample. Nothing in the task question states whether a pair landing exactly on the memory cap is legal, and the sample output settles it. For cores, the second sample only answers 3 if touching endpoints conflict. Treat the sample outputs as the specification and the hidden cases won't catch you out.

Asked at Wayfair

Four problems, heaviest first. Build the maze cold before anything else, since it is worth more than everything else on the paper put together.

1

Minimum Moves in a Maze: BFS With a Jump of Up to k

MediumSignature problem
Problem
A maze arrives as an n x m grid where every cell is either empty (0) or holds an obstacle (1). You start on (0, 0) and want to stand on (n-1, m-1).

A jump parameter k says how far one move can carry you. From (i, j), a single move lands on (i + x, j), (i - x, j), (i, j + x), or (i, j - x) for any 1 <= x <= k, provided the landing cell is inside the grid and every cell on the path, from the one beside you through the landing cell, is empty. An obstacle d cells away in some direction therefore kills every jump of d or more that way, while shorter jumps inside that distance remain legal.

Return the fewest moves that get you from (0, 0) to (n-1, m-1), or -1 when no sequence of moves reaches it. Reported constraints run to 1 <= n, m, k <= 100.
Inputmaze = [[0,0,0,0],[0,1,1,0]]k = 3Output2

Jump three cells right from (0,0) onto (0,3), then one cell down onto (1,3). The two obstacles in the bottom row never come into play.

How this uses the pattern

Every move costs one whatever distance it covers, so the cheapest route falls out of an unweighted breadth-first search over cells. Build a cell's neighbour list by stepping outward in each of the four directions up to k times, halting at the grid edge or at the first obstacle.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Minimum Moves in a Maze: BFS With a Jump of Up to k

Loading...
Click "Run" to execute your code
The Wayfair angle
Wayfair's HackerRank screen has leaned on this maze since late 2023. Fifty minutes covers two questions, this one weighted around 70 to 75 points against a companion worth 50, and 60 points is the cutoff for an interview. Partial credit is the common outcome, 6 of 15 cases in one sitting and 8 of 13 in another, and DFS runs out of time on the larger grids. A correct BFS still times out if it re-checks the whole span for every landing cell. That turns one expansion into k squared work and times out at 100 by 100 with k = 100. Some versions describe the obstacles as infinitely tall, which just means a 1 stops the jump.
Take it further
Return one minimum-move route as the list of cells you land on, from (0, 0) through (n-1, m-1), in place of the move count. Store a parent cell next to each distance, written the moment a cell is first reached, then walk the parents back from the far corner and reverse what you collected. Any route of minimum length is acceptable when several tie.
2

IP Zone Classification: Parse, Compare, Default to -1

EasyFrequently asked
Problem
You are given a list of IPv4 addresses as strings. Classify each address into a zone and return the zone numbers in input order.

The zone table is fixed, and the prompt expects you to declare it in your own source:

- Zone 1: 0.0.0.0 to 127.255.255.255
- Zone 2: 128.0.0.0 to 191.255.255.255
- Zone 3: 192.0.0.0 to 223.255.255.255
- Zone 4: 224.0.0.0 to 239.255.255.255
- Zone 5: 240.0.0.0 to 255.255.255.255

An address that is not a valid IPv4 string, or that lands in none of the zones, classifies as -1. Valid means exactly four parts separated by dots, every part a non-empty run of decimal digits, and every part's numeric value between 0 and 255 inclusive. "256.256.2.1" fails that test and classifies as -1 even though it has the right shape.
Inputips = ["0.0.0.123","129.234.233.24","256.256.2.1"]Output[1,2,-1]

0.0.0.123 sits under 127.255.255.255, so zone 1. 129.234.233.24 falls in the 128-to-191 band, so zone 2. 256.256.2.1 has octets above 255, so it is rejected before any comparison happens.

How this uses the pattern

Two steps per string, in that order: validate that you have four digit-only octets in 0 to 255, then fold those octets into a single 32-bit number. One number compared against the zone boundaries replaces every per-octet comparison you would otherwise have to get right.

Write it here, or go full screen with the problem, hints and solution beside the editor.

IP Zone Classification: Parse, Compare, Default to -1

Loading...
Click "Run" to execute your code
The Wayfair angle
Wayfair pairs this with the task-scheduling problem on the HackerRank screen, and candidates report the paper as 120 marks with 60 needed to advance, and 50 of those marks sit here. Clearing the scheduler alone leaves you short, so the cheap half has to come back clean. Two details in the prompt cost people marks. The zone table is yours to type out, since no library hands you those ranges. The sample input ships an invalid address, 256.256.2.1, in position three, so validation is scored from the first visible case.
Take it further
A natural escalation turns the zone table into an input: a list of [startIp, endIp, zone] triples that may leave gaps between ranges, with hundreds of thousands of addresses to classify. Sort the ranges by start once, then binary search each address's 32-bit value for the last range starting at or below it and confirm the value also sits under that range's end. Classification drops from O(z) per address to O(log z), and -1 then covers two situations, a malformed string and a value no range claims.
3

Task Scheduling: Same Type in Parallel Under a Memory Cap

MediumCommonly asked
Problem
A processor works through a batch of tasks. tasks[i] is the memory task i needs to run, task_types[i] is that task's type, and max_memory is how much memory the processor holds at one time.

Two tasks run in parallel only when they share a task type and their memory needs sum to at most max_memory. Nothing wider than a pair ever runs together. Every task takes 1 unit of time, so a single unit of time either runs one task alone or runs two paired tasks side by side.

Return the fewest units of time that finish the whole batch.

Assume every individual task fits under the cap on its own and all memory values are positive.
Inputtasks = [1,4,5,2,3]task_types = [1,2,1,3,4]max_memory = 6Output4

The two type-1 tasks need 1 and 5, summing to exactly 6, which the cap allows, so they share one unit. Types 2, 3 and 4 hold a single task each, and each of those takes a unit of its own. One shared unit plus three solo units is 4.

How this uses the pattern

Bucket the memory needs by task type, sort each bucket, then sweep it with two pointers from both ends. When the lightest and the heaviest fit together they share a unit, otherwise the heaviest spends a unit alone.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Task Scheduling: Same Type in Parallel Under a Memory Cap

Loading...
Click "Run" to execute your code
The Wayfair angle
Wayfair's HackerRank screen puts 70 of its 120 marks on this one question, with an IP-zone classifier carrying the other 50 and 60 marks needed to advance. It's harder to score on than it reads, because three conditions have to hold at once before two tasks share a unit: a matching type, a pair and never a trio, and a combined memory the cap allows. Code that honors only two of the three still clears the sample. The prompt leaves one thing open: whether a pair landing exactly on the cap is legal. Its sample answer settles it, since two type-1 tasks summing to exactly 6 against a cap of 6 still run together.
Take it further
The escalations keep the same two arrays. Lifting the parallel limit from two tasks of a type to k of them turns pairing into bin packing, and the tidy greedy answer disappears. Say so plainly instead of claiming the two-pointer sweep generalizes. Another direction holds the limit at two but asks for the schedule itself, which task ran beside which, so the return becomes a list of units rather than a count. A third drops the same-type rule for an explicit list of compatible task pairs, which makes the problem maximum matching on a graph and sits well beyond what an hour-long screen expects.
4

Minimum Cores: Count the Peak Overlap

MediumCommonly asked
Problem
Two integer arrays, starts and ends, describe n processes waiting on a machine. Process i holds a core from starts[i] through ends[i], inclusive at both boundaries. Return the fewest cores that can run all n processes.

A core takes a second process only once its current one has finished strictly before the next one begins. So a process ending at time 3 cannot hand its core to a process starting at time 3; that pair needs two cores. n runs as high as 1000, and n = 0 is a legal input whose answer is 0.
Inputstarts = [1,3,4]ends = [3,5,6]Output2

Processes [1,3] and [3,5] touch at time 3, so they cannot share. Process [4,6] begins after [1,3] has finished and reuses that core. Two cores cover all three.

How this uses the pattern

Pairing each start with its own end is the trap. Sort the two arrays independently, then walk a pointer through each one. Every start you serve claims a core, and a core comes back only when the smallest unretired end sits strictly earlier than that start. The highest count you ever hold is the answer.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Minimum Cores: Count the Peak Overlap

Loading...
Click "Run" to execute your code
The Wayfair angle
Wayfair asks this sweep in several forms. The intern HackerRank screen poses it as cores for overlapping processes, with a sample of start = [1, 3, 4], end = [3, 5, 6] answering 2 and n capped at 1000. A Karat screen frames it as something like a variation on the meeting room problem; another technical screening hands over Meeting Rooms II. One Karat sitting moved the idea into a mall, where every record carries a count of bodies and the ask becomes which time held the biggest crowd. Learn the boundary sweep once and all four become small changes to the same code. The sample output pins the convention down, since [1,2,3] against [3,3,5] only answers 3 if touching endpoints conflict.
Take it further
The mall variant swaps processes for foot traffic. Records arrive shaped like [count, time, flag], where flag marks an entry or an exit and count is how many people moved together. You return the time the mall was fullest. Two things shift. Each event moves the total by its own count rather than by one. Every event sharing a timestamp applies before you read the total, so an exit at time t is already out of the building at t.

Key Takeaways

  • ✓The screen is two problems in 50 minutes, reportedly 60 of 120 marks to advance. The grid question carries 70 to 75 of them.
  • ✓Both a one-cell and a k-cell jump cost one move, so BFS answers the grid. Mark on push and stop each direction at an obstacle.
  • ✓Both scheduling questions are sorted sweeps. Pair lightest with heaviest under the cap, and for cores walk the sorted boundary arrays together, tracking the peak.
  • ✓For the lighter question, check four digit-only octets at or below 255 before anything reaches the zone table, and return -1 on failure.
Wayfair interview guide

Know what Wayfair asks before you walk in.

30 coding · 4 system design · 24 behavioral questions

Get Premium$49 a year · Instant access
Or start freeNo card.

Get their questions first.

What Wayfair TestsHad your Wayfair interview?How we research

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.