Fractal Interview Question

SQL, leetcode medium to hard level