contains the whole code from JianZhiOffer