上一页 1 ··· 4 5 6 7 8 9 10 下一页
摘要: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. F 阅读全文
posted @ 2015-10-11 21:38 dylqt 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical an... 阅读全文
posted @ 2015-10-11 21:13 dylqt 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 一、动态内存与智能指针 1、new:在动态内存中为对象分配空间并返回一个指向该对象的指针;delete:接受一个动态对象的指针,销毁该对象,并释放与之关联的内存 2、两种指针:shared_ptr和unique_ptr;还有一个weak_ptr;都定义在memory中 二、shared_ptr类:智... 阅读全文
posted @ 2015-10-11 18:57 dylqt 阅读(292) 评论(0) 推荐(0) 编辑
摘要: 一、概述 1、关联容器中的元素是按关键字来保存和访问的;顺序容器中的元素是按它们在容器中的位置来顺序保存和访问的 2、关联容器:map和set map:元素是:关键字-值的对 set:每个元素只包含一个关键字 multimap:关键字可重复出现的map multiset:关键字可重复出现的set unordered_map:用哈希函数组织的map unordered_set:用哈希函数... 阅读全文
posted @ 2015-10-10 18:53 dylqt 阅读(188) 评论(0) 推荐(0) 编辑
摘要: #ifndef _Tree_H#define _Tree_Htypedef int ElementType;typedef struct TreeNode{ ElementType Element; struct TreeNode *Left; struct TreeNode *R... 阅读全文
posted @ 2015-10-09 11:01 dylqt 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 一、概述 1、大多数算法都定义在头文件algorithm中;头文件numeric中定义了一组数值泛型算法 2、一般情况下,这些算法并不直接操作容器,而是遍历两个迭代器指定的一个元素范围 算法永远不会改变底层容器的大小,想要改变必须使用容器自带的操作 二、初识泛型算法 1、理解算法最基本的方法是了解他们是否读取元素、改变元素或是重排元素顺序 2、那些只接受一个单一迭代器来作为第二个序列的算法,都假... 阅读全文
posted @ 2015-10-07 20:18 dylqt 阅读(194) 评论(0) 推荐(0) 编辑
摘要: Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12], after calling your fun... 阅读全文
posted @ 2015-10-07 16:06 dylqt 阅读(131) 评论(0) 推荐(0) 编辑
摘要: Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"]. 将没有重复,已经排好序的数组,返回下面的形式,如果连续就输出头尾的字符串,如果一个就返回一个字符 /** *... 阅读全文
posted @ 2015-09-28 14:20 dylqt 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 一、顺序容器概述:一个容器就是一些特定类型对象的集合1、顺序容器类型:vector、deque、list、forward_list、array、stringstring和vector将元素保存在连续的内存空间,所以用下标访问很快,但是在中间位置添加或删除元素很耗时list和forward_list在... 阅读全文
posted @ 2015-09-27 19:45 dylqt 阅读(201) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list, determine if it is a palindrome. Follow up:Could you do it in O(n) time and O(1) space? 1、朴素方法 /** * Definition for singly-linked list. * struct ListNode { * int val... 阅读全文
posted @ 2015-09-27 15:10 dylqt 阅读(222) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 下一页