LiveRamp interview question

How do you optimize the space complexity of BFS?