In a single prompt I would not expect that specific exercise to produce efficient code, but within a few prompts it should. Certainly less time than it would take someone to write it themselves.
There are always creative ways to squeeze extra performance out of code if you spend enough time on it.