Flatiron Health Interview Question

a problem about dfs