I faced when I visited New York. I had to search Google Maps and it showed a public toilet in Rockefeller Center. I walked a few miles to reach but it was a real pain.
No, it's not like you wanted it. You just wanted to pee, not a 500 kcal cookie.
(Yes you might need to buy something but seems like a small effort for it)
Plus it paints a wrong picture of a country because it's technically people asking you a few bucks for a basic necessity and the government has failed.
This is in stark contrast with developed countries like Singapore (where I visit a lot). Singapore makes sure a public toilet is available within a few hundred meters and boy are those clean!