数据结构
文章平均质量分 69
liutianjiacsdn
这个作者很懒,什么都没留下…
展开
-
二叉树非递归遍历(C++版本)
二叉树非递归遍历有三种方式:前序遍历、中序遍历、后续遍历前序遍历class Solution {public: vector preorderTraversal(TreeNode* root) { vector res; stack s; while (root || !s.empty()){原创 2017-06-30 17:18:44 · 515 阅读 · 1 评论 -
C++ 链栈实现
#include using namespace std;template class LinkStackNode{public:T data;LinkStackNode* next;LinkStackNode(T &d):data(d),next(NULL){}};template class LinkStack{public:原创 2015-05-13 16:16:52 · 1077 阅读 · 0 评论 -
20190819-社招记录
两个题都比较简单1.打印对角线输入 n = 3,矩阵是这样的:1 2 34 5 67 8 9打印结果:12 43 5 76 8932 61 5 94 87public class DidiMatrix { public void getResult(int n) { if (n <= 0) { return;...原创 2019-08-22 18:03:32 · 119 阅读 · 0 评论