Verkada interview question

Leetcode medium to hard problem