Are you sure the O2 sensor is bad? It could be wires, best to be sure before you spend money on the part. On my '99 Elantra you need to pull the heat shield on top of the exhaust manifold to get to the sensor. To remove the shield and the sensor, you'll need to use heat. The quickest method is with a torch, oxy/fuel or oxy/acetylene is the top choice, second best is a MAPP gas torch, third is propane.
You need to get the bolt heads holding the shield hot enough (shoot for dull red) to burn off all the rust (oxides). Let them cool down (cold) and the bolts will spin out. Do the same with the sensor but make sure you have the right socket first.