GGK Tech interview question

Print z pattern in one loop