Any Idea on how to solve this problem ? Can someone suggest me any Leetcode equivalent problem for it or some sort of basic idea. Thank you