Palantir: Total portfolio value per day with missing prices carried forward
Problem. You get several companies, each with a list of (day, price) pairs. Produce, for every day that appears anywhere in the input, the sum of all companies' prices on that day. When a company has no entry for a day, use the price it had most recently.
Example (as reported)
- Company A: day 1 = 200, day 5 = 100, day 8 = 50
- Company B: day 1 = 50, day 8 = 100
- Company C: day 5 = 50, day 8 = 200
- Reported output: day 1 = 300, day 5 = 200, day 8 = 350
Watch out. The reported numbers only add up if a company with no earlier price uses its first known price for days before it appears (company C on day 1). Ask the interviewer how that case should be handled before you write code; this ambiguity is the real trap in the question.
Context. This was the only coding problem in a technical screen for an intern role, rated medium. No constraints or follow-ups were reported, so be ready to talk about sorting the union of days and walking each company's list in step.
Comments 0
No comments yet. Ask the author something, or add what happened in your own round.