Match Specific Pattern

https://practice.geeksforgeeks.org/problems/match-specific-pattern/1

How can I Approach this Question?