The solution is not perfect, as too many nodes are marked as terminal but the output is correct (too much work is done on the boundary)
The solution is not perfect, as too many nodes are marked as terminal but the output is correct (too much work is done on the boundary)