LG Soft India interview question

Leetcode medium question. Bulls and cows.