Got the same question as this one:
https://leetcode.com/discuss/post/4159607/datadog-onsite-rm-rf-by-anonymous_user-e3bf/
- Asked to implement a solution. Implmented a recursive DFS solution.
- Follow up was to update the code to avoid OOM issue.
- Suggest that we can use iterative approach instead of recursion.
- Had in depth discussion on why recursive solution can cause OOM issue.
- Interviewer followed up with sharing that file structure is not deep but rather wide. Say max directory depth is only 10 but the number of files in the directory are in millions.
- Suggest a BFS based approach. Interviewr was happy with the approch and implementation.
- Moving on to the next round !!