Stable marriage problem is an optimal matching problem of two groups. There are two groups A and B. A has the ranked preference order of B. So does B. Firstly, matchings are made by A's preference then if there is duplication, B's preference priority is applied until everyone is matched.