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 }

 

相关文章:

  • 2022-12-23
  • 2021-12-25
  • 2021-08-07
  • 2022-01-17
  • 2021-08-10
  • 2021-12-08
  • 2021-07-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案