3 ms·
Like another commenter I think pretty much anything after DFS/BFS is asking a bit much during a normal interview. Floyd-Warshall? I guess it might be doable if
by Jach 10y ago
Like another commenter I think pretty much anything after DFS/BFS is asking a bit much during a normal interview. Floyd-Warshall? I guess it might be doable if you have a mathematical description handy, I've only implemented it once for a school assignment and don't remember how long it took but it's not something I'd ask or expect to be asked... I sometimes get asked to do interviews, I'm always torn by a desire to shake things up with the broken interview process but also somewhat conform to management expectations and feedback I can give like "was able to solve Arbitrary Parts of Arbitrary Programming Challenge X." In phone screens I spend ~10 mins on data structures, I'll ask some graph representation questions if they seem like they don't have an issue with others.
In longer settings (at least an hour) and especially if I know other interviewers are asking other things I'll ask them to solve a problem and actually write code on a computer. A problem I sort of like is https://leetcode.com/problems/jump-game/#/description https://leetcode.com/problems/jump-game/#/description While I think there's a pretty simple solution that just loops over every element, what I did when I tried solving it myself was recognize it's a search problem and apply the generic search algorithm to it. (Create a frontier list with an initial starting point. Create a seen/visited set. While the list isn't empty, pop an item off. If it's what you're looking for, you're done. Mark it seen, expand its children and for each one add it to the frontier list if it hasn't already been seen.) Knowing the generic (iterative) algorithm is to me more important than the particulars of DFS/BFS (you can control which one by choice of data structure), I just want to visit all reachable nodes in my search space and it works. Of the several people I've given this to only one has solved it, and by solve I mean had any right approach even if non-compiling/terrible code. (They ended up using a BFS approach.) They also are a promotion level above mine and have had more years of experience. So maybe I need to retire it, but I still like the idea of seeing if someone can recognize a search problem and solve it because there are usually many ways of solving search problems.