Approach to solve this

is my approach to solve this problem is correct or not.

hello @shivamgoel150
yeah your approach is correct.