Just finished the interview, don't know the result yet, but I feel like I answered pretty mediocre.
It really was the question that's already posted here — Merkle Tree — but the details still mattered a lot.
It runs inside an actual repo, so you have to read files from the repo, which means you need to be familiar with the relevant standard library.
The interviewer wanted the folder structure to represent the tree structure, which is very different from the binary tree you'd practice on your own — there are all kinds of differences in the details, and at that point there's no point discussing whether the tree is balanced or not.
It runs inside a repo, so the result needs a real data structure — it's better to model it as (added, modified, removed) from the start. As it turned out, I never even finished writing my comparison function, and what I did write was wrong.
Since I didn't finish, I never even got the chance to discuss or use any of the follow-ups.
Anyway, it really did feel realistic — not like a pure LeetCode algorithm problem. It has to actually run in a real environment against a real problem, which I think is pretty different from most other companies. Honestly, even if you've written this exact thing before, you might not have time to reproduce it from memory.
I think good interface design still matters a lot — even if you feel like you and the interviewer have already talked it through verbally, it's still worth nailing it down precisely:
from enum import Enum, auto
from typing import Self
class ChangeType(Enum):
ADDED = auto()
MODIFIED = auto()
REMOVED = auto()
class MerkleTree:
def __init__(self, root_directory: str):
pass
# List of changed files and change types
def diff(self, other: Self) -> list[tuple(str, ChangeType)]:
pass
Discussion
Loading comments…