Can I go to a public pool not knowing who will be there with the intention of not falling into haram

If there is like an isolated corner where you swim it’s ok to go. But if you know that it will be mixed and you will see the opposite gender in swimsuit, and swim by them, you cannot go.