@Srestha ... How long it took you to ans this question, I am asking this because form me its at least 10 min.

How to solve this type of question in quick time. Any trick ..? If yes then please let me know.

First I thought of doing it for general case but it is taking very much time.