Inflationen i euroområdet og EU nåede et treårigt højdepunkt på 4 procent i oktober på grund af de stigende energiomkostninger.