It is not considered rude to leave a lecture if you have a legitimate reason for doing so. However, it can be distracting for others and may be perceived as impolite if done frequently or without explanation. For this, it’s best to sit towards the middle of the row to allow others to move in and out easily.