I got enlightment:pick a pen and a piece of paper, and simulate the procedure by drawing- this strategy is working so well on diagram-like problems! Just like "starting from enumeration and check pattern" strat
Compared with I version, the tree could be incomplete. The only difference is that, we connect current node's child to next non-childrenless' node's first child. Still, we need calculate from right to left: classSolution {public:voidconnect(TreeLinkNode *p) {if(!p)return;if(p->right)...