AT&T Interview Question

Star method was used for complete solutions