96 Nissan Maxima, possible bad 02 sensor?

I was driving back to school from spring break this past week in my 1996 Nissan maxima and the trip with fairly uneventful, until the CEL(check engine light) came during the last 20 minutes of a 6 hour drive. I stopped by auto-zone and had them read the error codes off and I had two of them;

-P0136, Oxygen Sensor

-P0325, Knock Sensor

I was wondering if these were related or do I need to just replace the 02 sensor? I don’t know if this has anything to do with it, but I changed things up this trip and used 87 octane gas instead of the recommended 91, the manual said it was fine for non-performance driving…and I am pretty low budget, so I figured it’d be worth a shot. The car has 140,000 miles on it so I was also just thinking that the sensor went bad with age, there was no notable change in the way the car worked…

Thanks for your input!

These codes could have been triggered by the 87 octane and yes, they could be related.
Normally, you might not have a problem running 87 but if there is an EGR system fault (which can exist with no codes) then the problem can be exacerbated by the 87.

At 140k miles it’s possible the EGR passages could be clogged up and a thorough cleaning could cure this problem.
(The EGR system lowers combustion chamber temps and if inoperative could lead to subtle pinging, knocking if you will, which could then lead to the O2 sensor not being able to keep up with things. Sometimes an application of a good cleaner like SeaFoam, Berryman, etc. into the intake may help clear this up, depending on how severe any clogging is. Think of a sooted up chimney as an analogy.)