摘要:
二叉树及其遍历 push为前序遍历序列,pop为中序遍历序列。将题目转化为已知前序、中序,求后序。 前序GLR 中序LGR 前序第一个为G,在中序中找到G,左边为左子树L,右边为右子树R。 将左右子树看成新的树,同理。 An inorder binary tree traversal can be 阅读全文
摘要:
Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given s 阅读全文
摘要:
由于最近学的是线性结构,且因数组需开辟的空间太大。因此这里用的是纯链表实现的这个链表翻转。 Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements 阅读全文