1 void getPostFromPre(int preL, int preR) { 2 if (preL > preR) return; 3 int i = preL + 1, j = preR; 4 while (i <= preR && pre[i] < pre[preL]) i++; 5 while (j > preL&&pre[j] >= pre[preL]) j--; 6 7 if (i - j != 1) return; 8 getPostFromPre(preL + 1, j); 9 getPostFromPre(i, preR); 10 post.push_back(pre[preL]); 11 }
原文地址:https://www.cnblogs.com/fuqia/p/10358958.html
时间: 2024-10-29 19:11:05