Interviewing

# Getting Ready for a Technical Interview? Try These Practice Qs from Our Friends at Hackbright

In the best of times, it’s normal to feel nervous about applying for a job, especially a technical one that demands a demonstration of skill.

Now, of course, it’s a whole new level of weird and worry. Totally remote interviews. Having a team lunch on Zoom instead of an onsite catered lunch. Attempting to gauge culture fit through a screen. One upside – no more whiteboard – which admittedly makes us really happy.

Regardless of the interview setup, you’re still going to have to crush it in your technical interview. Give these amazing questions from Hackbright a shot to test your skills (oh, and check out their advice for job seekers too!).

Before you start: try these answers out using CoderPad’s sandbox here. Or find a friend and practice interviewing each other with CoderPad’s free candidate account available here.

### Leveret Lunch Overview

“Leveret” is a fancy word for a baby bunny (okay, technically, a leveret is a young hare but baby bunny sounds better) and like all baby animals, they have huge appetites.

### Leveret Munch (Easier)

Baby Leveret is hopping down the garden trail in a quest to devour as many carrots as she can.
Each plot along the trail contains a certain number of carrots. We can represent the number of carrots in each plot as an element in an array of integers, where each number represents a plot:

``````        [4, 5, 3, 5]
``````

Baby leverets can only eat a total of 10 carrots, and not any more. Given an array formatted like the one above, a baby leveret could eat 2 full plots of carrots. Here’s an explanation.

``````        # Baby Leveret starts at the garden gate

[4, 5, 3, 5]    4 carrots eaten, 1 plot consumed
?

[4, 5, 3, 5]    9 carrots eaten, 2 plots consumed
?

[4, 5, 3, 5]    12 carrots eaten - too many! Stop here.
?
``````

#### The Challenge

Write a function that takes in an array of integers that represent the number of carrots in each plot in a garden trail. This function should return the number of plots a baby leveret will eat, only counting plots that can be eaten in completion. (A leveret can’t eat part of a plot.)

### Question Two: Leveret Lunch (Medium)

Our hero, Baby Leveret, starts in the middle of a garden and eats carrots until she falls asleep.
The garden is a grid that is nrows tall and ncols wide. Each plot in the garden has a particular number of carrots in it.

Baby Leveret will dig a little tunnel all the way to the center of the garden, where she’ll start her feast. If the center of the garden consists of more than one plot, she’ll choose the plot with the most number of carrots to start (assume there will never be a tie between multiple plots) and eat allllll the carrots there.

Then, she’ll look around at neighboring plot to sniff out the one with the most carrots. She always sniffs the plot to her west first (left), then north (up), then east (right), then south (down); if there are two or more plots that tie for the highest number of carrots, she’ll hop to the first plot her nose encountered (that is, the first plot she encountered in west-north-east-south order).
Once there are no neighboring cells with carrots, she falls asleep for a well-deserved nap.
For example, consider this garden:

``````         A   B   C   D   E   F   G
+---------------------------+
1  | 2 | 3 | 1 | 4 | 2 | 2 | 3 |
|---+---+---+---+---+---+---|
2  | 2 | 3 | 0 | 4 | 0 | 3 | 0 |
|---+---+---+---+---+---+---|
3  | 1 | 7 | 0 | 2 | 1 | 2 | 3 |
|---+---+---+---+---+---+---|
4  | 9 | 3 | 0 | 4 | 2 | 0 | 3 |
+---------------------------+
``````

There are two center cells, at D2 and D3. The cell at D2 has more carrots (4 versus 2), so Baby Leveret starts there and eats the 4 carrots at D2.

She then looks at the neighbors in WNES order and finds the highest carrot count is at D1. She eats the 4 carrots there.

Looking WNES, she finds there are more carrots at E1, and moves there and eats the 2 carrots there.

Looking WNES, she sees more carrots at F1, and moves there and eats the 2 carrots there.

Looking WNES, she sees 3 carrots both east and south — but since there’s a tie, she goes in WNES order, so heads east and eats the 3 carrots at G1.

Looking WNES, she finds only neighbors with 0 carrots, so she takes her post-lunch nap.

In total, she’s eaten 4 + 4 + 2 + 2 + 3 = 15 carrots.

#### The Challenge

Write a function that takes in a 2-dimensional array that represents garden plots and the amount of carrots each plot contains. This function should return the number of carrots eaten by Baby Leveret.