2006 Toyota Corolla

I have a 2006 Toyota Corolla. The other day I was pulling out of the parking lot and it stalled. I tried to start it back up but it didn’t. I waited a while and it did start back up but the “check engine light” was on. I drove it around the block and it was ok. I checked to make sure the gas cover was closed and it was. The next day the light was off so I figured it was ok. Two days later I am pulling out of the parking lot and it did the same thing. When I tried to restart it it wouldn’t. It sounds like the engine isn’t clicking over and catching to start up. I am thinking and alternator, a starter, or an engine coil? Any ideas on what it is and what the cost is to fix it?