简单版
https://www.cnblogs.com/Sebastian-Wang/p/6047068.html
复杂版
https://www.cnblogs.com/zhi-leaf/p/11509186.html