Not a typical algorithm question. Need recursion, divide into different situations, and consider many edge cases. I think the question's difficulty level is far higher than the requirement for a mid-level data engineer
Check out your Company Bowl for anonymous work chats.