Check diagonal and compute window statistics | Meta Interview Question