There are a few different standards that can be used to define efficiency in an economic sense, but the most commonly used is what we call Pareto efficiency.
If a market is Pareto-efficient, it is impossible to redistribute goods in such a way that we could make one person better off without making anyone worse off.
I think this is worth explaining a bit further; at first glance, many people often infer that Pareto efficiency is very easy to obtain. "Obviously, if I take something from you and give it to someone else, you are worse off. Therefore it is Pareto-efficient." This is incorrect. A market is only Pareto-efficient if every good is being used by the person who values it most.
An example might help: Suppose you have 400 bushels of corn, and I have 300 bushels of wheat. Suppose, furthermore, that you like wheat better than corn and I like corn better than wheat. This setup is not Pareto-efficient, because if I give you all my wheat in exchange for a bunch of your corn, we are both better off, because you like wheat better and I like corn better.
In practical terms, we generally infer that a market is Pareto-efficient if total surplus is maximized; this is composed of two components: consumer surplus, which is the difference between how much consumers value the goods they have and how much they had to pay for them, and producer surplus, which is the difference between how much was paid for goods and how much it cost to produce them. Adding these up, the price paid for the goods becomes basically irrelevant; all that changing the price does is redistribute surplus from consumers to producers or vice-versa.
Where prices do matter is by influencing the actual number of goods produced and sold. If the price is either too high or too low, markets will not clear; either supply will exceed demand, or demand will exceed supply.
The basic market structures to be concerned about are perfect competition, monopoly, monopsony, oligopoly, and monopolistic competition. Oligopoly and monopolistic competition are the most common systems in the real world, but they are basically complex hybrids of the other three basic types.
Under perfect competition, there are many buyers and many sellers, and no one person has the power to significantly influence the price. In perfect competition, the price will naturally seek its market-clearing level, and total surplus will be maximized. Thus, perfect competition is efficient. The market for wheat is close to perfect competition.
Under monopoly, there are many buyers, but only one seller. That seller has the power to set the price they want. If they can set different prices for different people, they can use price discrimination, which allows them to produce goods for everyone who wants them (more strictly, everyone who wants them enough to pay more than the marginal cost of making them); this maximizes total surplus and is therefore efficient; however, the monopoly seller gets all the surplus. If they must set the same price for everyone, they instead produce less than they could, in order to charge a higher price. This is not efficient, because the resulting total surplus is less than it would be under perfect competition. The market for any new drug, still under patent, is effectively a monopoly.
A monopsony is the inverse of a monopoly; there are many sellers, but only one buyer. Again, if the monopsony buyer can use price discrimination, the market will be efficient but the monopsony will capture all the surplus. If not, the monopsony will purchase less than they could, in order to buy at a lower price. This is not efficient, as it results in less total surplus than perfect competition. The market for military contracts from the government is a monopsony.
An oligopoly has a small number of sellers, but more than one; it can behave like a monopoly, or like perfect competition, or somewhere in between, depending on the complex interactions between different companies. To really understand oligopoly you need game theory. Many real-world markets are oligopolies, such as soft drinks (Coke and Pepsi), computer operating systems (Apple and Microsoft) and commercial airliners (Boeing and Airbus).
Monopolistic competition is a system in which there are many sellers, but they are each different from each other, so that in a sense, there is really only one seller of each precise type of good. Thus, they can act somewhat like a monopoly on that good--but not too much like a monopoly, because if they set their price too high then people will start buying different goods instead. Monopolistic competition is usually not efficient, but it typically becomes more efficient over time as more companies enter the market and it thereby gets closer to perfect competition. Most real-world markets are under monopolistic competition, from t-shirts to cheesecakes and pencils to sunglasses.