Optiver interview question

Medium/hard leetcode graph search question