Virtu Financial Interview Question

CodeSignal like coding problem, medium LC difficulty DSA problem