MAQ Software interview question

simple codes can be gound on geekforgeeks