LiveRamp Interview Question

How do you optimize the space complexity of BFS?