Structure a technical interview

General Do’s


Assumptions, Approach, Implementation


Clarify Assumptions

Example: Anagrams

Clarify every single thing, no matter how small. This is the time to be pedantic. Clarify every ambiguity you can think of. Ask questions even if you’re almost sure you know the answers.

It gives you a chance to come up with edge cases and fully spec the problem (seeing how you handle edge-cases is one of the main things that interviewers look for when evaluating an interview)

It gives you a minute to collect your thoughts before you need to start solving the problem.

Problem: Delete a course named 6.000 from list.

Partition:
subjects.size: 0, 1, n
contents: no 6.xx, one 6.xx, all 6.xx.
position: 6.xx at start, 6.xx in middle, 6.xx at end

If it’s a problem related to trees, I would start with the null case, one node, two nodes, three nodes. This can help you generalize a solution.

“Can I assume the input array is sorted?”

I remember one interview solution that relied entirely on all the inputs being positive integers, but I almost failed the interview because I couldn’t figure out what to do when I got zero as an input. If I would have read the problem more carefully, I would have realized that zero was not included in the possible inputs.

How to expose elements of the data structure? Should I implement the the iterable interface by providing an iterator()?

Implement data structure with Generics or assume a type used by the user int/string


Discuss Approach

Not sure how to find the 4th largest item in the set? Think about how to find the 1st largest item and see if you can adapt that approach.

Example: Project a triangle onto a plane, a typical graphics problem, and I don’t mind helping them with the trig (SOH-CAH-TOA, baby!), and when I ask them how to speed it up, I might drop little hints about look-up tables. Notice that the kinds of hints I’m happy to provide are really just answers to trivia questions—the kinds of things that you find on Google.



Write Code


Test by walking through examples

How do you know the code works? How do you design a unit test? What kinds of conditions do you assert in the code? How do you debug a crash? What if it’s intermittent? What types of mistakes lead to intermittent bugs?

Possible sources of bugs:

With string functions in C, most college kids forget to null-terminate the new string. likely to have off-by-one errors.
forget semicolons sometimes.
Won’t work correctly on 0 length strings
GPF if malloc fails… Integer Overflow Mutable Objects


Discuss performance

Think about extreme quantities. For example, if the problem is about lists, mention that you would have a case with a large list and a really small list. If it’s about numbers, you’ll test the maximum integer number and the smallest.



References

31 March 2019