TikTok Interview Question

2 leetcode questions per interview. Medium to hard level.