Bloomberg interview question

2 leetcode medium problems and come up with their analyses.