October through April (approximately)
From fall through early spring, you may be able to find a campsite at one of the reservation campgrounds or at Wawona and Hodgdon Meadow Campgrounds, which operate on a first-come, first-served basis from October through April. You can also double-check the reservations website to check for any last-minute availability.
May through September (approximately)
Note that very few first-come, first-served campsites are available in May and June (until additional first-come, first-served campgrounds open).
In order to have a reasonable chance of finding a campsite from spring through fall, you should arrive by noon on weekdays and midmorning on weekends. (Camp 4 usually fills by 9 am; Tuolumne Meadows Campground may fill by 8:30 am on Fridays and Saturdays.)
Once you get a campsite, you can register for more than one night. In May and June, you're very unlikely to find a first-come, first-served campsite (until later in June, when additional campgrounds open).
If all else fails, try to find a campsite outside of Yosemite National Park.