Any subtenant who pays or discharges any debt or lien which the landlord has against the tenant in chief, by contract, judicial process, or otherwise, shall be subrogated to the rights, liens, and remedies, which the landlord had against the tenant in chief as to such debt or lien so paid or satisfied, or he may set off such debt, claim, or demand so paid or discharged by him against any claim, debt, or demand which the tenant in chief may have against such subtenant.