Block interview question

Medium leetcode problem and advanced SQL.