Solomon asked for wisdom to guide the people rather than long life or revenge. He was blessed even though he had made a marriage alliance with Pharoah.
He received wisdom from God as illustrated by the prostitutes coming to him for justice. Besides the wisdom to figure out who was the mother, he was willing to listen carefully to two prostitutes. Justice isn’t just figuring out the solution. It is also the patience to listen to people who don’t deserve it.
Again we have a greater than Solomon. We should turn to Him for wisdom when we need it. He will listen and help.