There are several problems in The BFG by Roald Dahl, all of which are resolved by the ending. The first is that of Sophie, a young orphan who is kidnapped by the BFG. On the one hand she likes him, and wishes him no harm, but she also wants to return to human society.
The second problem is that of the cannibalistic giants who are stealing young children and eating them. The BFG isn't strong enough to defend children from them. The giants are planning to abduct a mass of children from their schools.
Finally, there is the problem of finding food (other than children) which is palatable.
The solution involves the BFG sending a dream to the Queen of England and then having Sophie explain the dream to the Queen. With the help of the Queen and the Army, Sophie and the BFG thwart the plot of the cannibals and are providing food and housing where they can live safely and happily on the palace grounds.