Everpure interview question

2 leetcode problems pretty straightforward