A community college district is set to buy a Cupertino apartment complex to help students facing sky-high housing costs.