Where it comes from

How to answer

Palantir’s company-wide guide to its coding interviews tells candidates to think about edge cases and the ways their code could break; it is not specific to the role. Source 1Writing Good CodePublisherPalantirSource typecompany hiring page This question makes that the whole task, so the list is what gets judged. A list is only useful if each line says what should happen.

  1. Pin the contract in one breath. What comes in, what comes out, and what failure looks like: an exception with a reason code, a None, or a partial result. You cannot say an input breaks the parser until you know what correct means.
  2. Walk a fixed set of categories out loud: empty, malformed, boundary, huge, unicode, and valid but surprising. A fixed order keeps you from stalling after the obvious three.
  3. Give a concrete input for each, with its expected result. Not “unicode” but "1h" typed on a Japanese keyboard, and whether it is accepted.
  4. Mark the product calls and ask. Whether a bare number means minutes is not yours to decide silently.
  5. Name the traps of your language. In Python, \d, str.isdigit() and int() accept digits from other scripts, and $ matches before a trailing newline.
  6. Turn the list into a test table before the parser exists. It becomes the spec, and you run it at the end.

The trap is a list of category names with no inputs and no decisions. It sounds thorough and settles nothing.

GlossaryForward deployed engineerA software engineer who builds and ships production systems inside a customer’s problem and environment, accountable to that customer’s outcome.More on Forward deployed engineer

Follow-ups

What the interviewer may ask next, once your first answer is on the table.

  • Which of these would you reject, and which would you quietly fix? Who decides?
  • The same field is filled in by users in Japan. What changes in your list?
  • How would you find the inputs you did not think of?
  • This parser runs on every request. Which of these inputs could hurt the service rather than the one caller?

Where answers go wrong

  • Naming categories (“nulls, empty strings, big numbers”) with no concrete input and no expected result for each, so the list decides nothing.
  • Writing the parser first and the list afterwards, so the list describes what the code happens to do rather than what it should do.
  • Trusting \d or str.isdigit() to mean ASCII digits. In Python both accept digits from other scripts, such as Arabic-Indic ١, and int() converts those; isdigit() also accepts superscripts like ², which int() rejects.

Answer this in two minutes

Write the answer you would say out loud. The clock starts with your first word.

Two minutes

Model answer

The interviewer’s parser: turn durations that people type into a scheduling field, such as 1h30m or 45m, into seconds. The scheduler refuses anything over 30d.