Brzozowski's algorithm (co)algebraically