Netskope interview question

2 leetcode medium question on stack and hashmap based