Tesla interview question

They asked a relatively easy and a medium Leetcode question in the coding assessment.