"Twice a day" is not an answer. Two different dogs need completely different things in the same amount of time, and getting it wrong in either direction shows up in behaviour at home.
Adult dogs
Small breeds: two outings a day, around an hour in total. Medium: an hour and a half to two hours. Large and working breeds — huskies, shepherds, malamutes, gundogs: two to three hours, and that is not an exaggeration. A dog bred for hours of work does not switch off because it lives in a flat.
Puppies
Until the post-vaccination quarantine is over, only in your arms or on your own property. After that the rule of thumb is about five minutes of walking per month of age, per outing. Fifteen minutes at three months, half an hour at six.
The limit is not about tiredness but about joints: a puppy's growth plates are vulnerable, and long walks, stairs and jumping at this age turn into problems years later. You can, however, go out more often — four or five short outings beat two long ones.
Older dogs
Total time drops; the number of outings does not. An old dog needs to go out just as often, but slower and for less time. A simple guide: if the dog limps or struggles to get up the next morning, reduce the load.
What most people miss
A dog is tired out by its nose, not by distance. Twenty minutes spent letting it sniff bushes, posts and grass at its own pace drains it far more than an hour of brisk walking on a short lead beside you.
This is the cheapest fix for an energetic dog in a flat: not running faster, but allowing sniffing. Let the lead out where it is safe, and do not pull on while the dog is reading.
Signs you walk too little
Chewing, digging, barking at sounds behind the door, unable to settle in the evening, greeting you frantically, waking you at night. This is almost never "character" or "naughtiness" — it is an unspent day.
Signs you overdo it
Refusing to walk on, lying down mid-walk, limping, breathing hard long after getting home, sleeping through the next day. In puppies and old dogs, this is the more common failure.
Weather
In hard frost, small and short-coated dogs need a coat and the walk shrinks to the essentials. In summer, walk early and late rather than at midday: tarmac holds heat, and paws burn before the dog shows any sign of distress.