The interviewer was looking over my resume while I gave my self-introduction, and after I finished he asked about a project from my background — a project building a model, and he asked about offline evaluation for the model.
Coding: given a set of time-window intervals, merge all overlapping intervals. Input: [[1,3],[2,6],[8,10]], output: [[1,6],[8,10]]. My approach: first sort by each interval's start value. Then go through the remaining intervals — if the current interval's start value is less than or equal to the end value of the last interval in the result list, merge them.
After that he also asked about the sorting logic and how I handled edge cases.
Round 2: the interviewer asked about my project on performance optimization — what tools I used, that kind of thing — and then moved into coding.
Coding: given the total number of courses and a list of prerequisite relationships, determine whether it's possible to finish all the courses. Input: numCourses = 2, prerequisites = [[1,0]], output: true. My approach: this is usually solved with topological sort — build a directed graph, compute the in-degree of each node, add the nodes with in-degree 0 to a queue, and remove them one at a time.
Discussion
Loading comments…