Gridlex interview question

Asked some medium and hard level Leet code questions