上一页 1 ··· 26 27 28 29 30
摘要: Description:Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in ... 阅读全文
posted @ 2015-06-14 09:02 Rosanne 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 问题描述Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example: Given bi... 阅读全文
posted @ 2015-06-13 16:12 Rosanne 阅读(154) 评论(0) 推荐(0) 编辑
摘要: KMP算法是一种改进的字符串匹配算法,由D.E.Knuth与V.R.Pratt和J.H.Morris同时发现,因此人们称它为克努特——莫里斯——普拉特操作(简称KMP算法)。KMP算法的关键在于:每当一次匹配过程中出现比较不等时,不需回溯i指针,而是利用已经匹配得到的“部分匹配”的结... 阅读全文
posted @ 2015-05-20 11:46 Rosanne 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 重构二叉树的思路主要是首先在前序(后序)序列中找到根结点,然后在中序序列中找到根结点所在的位置,该结点将整个序列分成两个部分,前一部分为根结点的左子树元素,后一部分为根结点的右子树元素。再递归的生成左子树和右子树即可。 1.通过前序,中序序列重构二叉树 TreeNode * buildTree(ve 阅读全文
posted @ 2015-05-19 14:50 Rosanne 阅读(322) 评论(0) 推荐(0) 编辑
摘要: Given preorder and inorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not exist in the tree.class ... 阅读全文
posted @ 2015-05-19 13:37 Rosanne 阅读(147) 评论(0) 推荐(0) 编辑
摘要: AVL(Adelson-Velskii and Landis)树是带有平衡条件的二叉查找树。其每个结点的左子树和右子树的高度最多差1. 在高度为h的AVL树中,最少结点数S(h)=S(h−1)+S(h−2)+1。对于h=0,S(h)=1;h=1,S(h)=2。AVL的树的结点声明st... 阅读全文
posted @ 2015-05-14 22:06 Rosanne 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 树结点的声明struct BinaryNode{ char element; BinaryNode* left; BinaryNode* right; BinaryNode() { element = ' '; left = right = ... 阅读全文
posted @ 2015-05-07 21:45 Rosanne 阅读(379) 评论(0) 推荐(0) 编辑
摘要: Description:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents... 阅读全文
posted @ 2015-05-07 13:31 Rosanne 阅读(219) 评论(0) 推荐(0) 编辑
上一页 1 ··· 26 27 28 29 30