Databricks Interview Question

DFS in constant space