LG Soft India Interview Question

Leetcode medium question. Bulls and cows.