摘要: 这个题目其实不难的,主要是我C++的水平太差了,链表那里绊了好久,但是又不像用python,所以还是强行上了。 题目如下: Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Give... 阅读全文
posted @ 2014-11-22 16:37 Tiny-Box 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 这道题的无聊之处在于题目其实给了一些很奇怪的测试用例。比如他会给一些空的数组来,但是这个是不科学的,因为在C++中不允许定义一个空的列表,我们用的又不是那种糙又快的python,所以在这里我遇到了一些问题,后来还是解决了。这道题题目如下:Given two sorted integer arrays... 阅读全文
posted @ 2014-11-20 22:56 Tiny-Box 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 这个取决于今早看耗子叔的微博: 这里说到了int的取值范围的问题,int的取值是-2147483648 ~ 2147483647,但是如果直接在编译器(VS2013)中使用-2147483648会报错: error C4146: 一元负运算符应用于无符号类型,结果仍为无符号类型 编译器(VS2013)在看到-2147483648时,会先做一个判断,就是先做一个2147483648 > INT_... 阅读全文
posted @ 2014-11-18 16:38 Tiny-Box 阅读(858) 评论(1) 推荐(1) 编辑
摘要: 因为我刷题是难度不是按发布日期,所以就有可能遇到这种情况,比如这个。。。Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal i... 阅读全文
posted @ 2014-11-18 13:40 Tiny-Box 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 这次我觉得我的智商太低,想了很久才写出来。题目是让求镜像二叉树判断,题目如下:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this... 阅读全文
posted @ 2014-11-18 12:57 Tiny-Box 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 跟第七题一样,把最后的输出顺序换一下就行。。。Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For exampl... 阅读全文
posted @ 2014-11-15 20:59 Tiny-Box 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 可能是因为我是按难度顺序刷的原因,这个其实在之前的几道题里面已经写过了。题目如下: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf nod... 阅读全文
posted @ 2014-11-15 20:53 Tiny-Box 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 这次相对来讲复杂点,题目如下: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example:Given binary tree {3,9,... 阅读全文
posted @ 2014-11-15 00:44 Tiny-Box 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 这个题目纠结了一会儿,终于从二叉树转化到AVL了。题目如下:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a ... 阅读全文
posted @ 2014-11-13 11:18 Tiny-Box 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 二叉树基本功练习题,题目如下:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to... 阅读全文
posted @ 2014-11-12 19:43 Tiny-Box 阅读(78) 评论(0) 推荐(0) 编辑