摘要: 转自http://www.cppblog.com/wanghaiguang/archive/2012/06/05/177627.htmlSTL Set介绍集合(Set)是一种包含已排序对象的关联容器。多元集合(MultiSets)和集合(Sets)相像,只不过支持重复对象,其用法与set基本相同。S... 阅读全文
posted @ 2015-07-23 15:20 鸭子船长 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 转自http://blog.csdn.net/lskyne/article/details/10418823Lists将元素按顺序储存在链表中. 与 向量(vectors)相比, 它允许快速的插入和删除,但是随机访问却比较慢.assign() 给list赋值back() 返回最后一个元素begin(... 阅读全文
posted @ 2015-07-23 15:12 鸭子船长 阅读(4271) 评论(0) 推荐(0) 编辑
摘要: 转自http://www.cnblogs.com/marchtea/archive/2012/02/27/2370068.html总所周知,c++的stl中提出了iterator的概念,这是C所没有的.在一般的使用中,iterator的行为很像c内建的指针.而在java和c#中索性就直接取消了指针,... 阅读全文
posted @ 2015-07-23 14:50 鸭子船长 阅读(555) 评论(0) 推荐(0) 编辑
摘要: C++map的基本操作和使用来源:(http://blog.sina.com.cn/s/blog_61533c9b0100fa7w.html) - C++map的基本操作和使用_Live_新浪博客 Map是c++的一个标准容器,她提供了很好一对一的关系,在一些程序中建立一个map可以起到事半功倍的效... 阅读全文
posted @ 2015-07-23 14:47 鸭子船长 阅读(238) 评论(0) 推荐(0) 编辑
摘要: Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matr... 阅读全文
posted @ 2015-07-23 12:35 鸭子船长 阅读(146) 评论(0) 推荐(0) 编辑
摘要: Given acompletebinary tree, count the number of nodes.Definition of a complete binary tree fromWikipedia:In a complete binary tree every level, except... 阅读全文
posted @ 2015-07-23 12:34 鸭子船长 阅读(162) 评论(0) 推荐(0) 编辑
摘要: Find the total area covered by tworectilinearrectangles in a2Dplane.Each rectangle is defined by its bottom left corner and top right corner as shown ... 阅读全文
posted @ 2015-07-23 12:33 鸭子船长 阅读(147) 评论(0) 推荐(0) 编辑
摘要: Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top()... 阅读全文
posted @ 2015-07-23 12:32 鸭子船长 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Implement a basic calculator to evaluate a simple expression string.The expression string may contain open(and closing parentheses), the plus+or minus... 阅读全文
posted @ 2015-07-23 12:32 鸭子船长 阅读(148) 评论(0) 推荐(0) 编辑
摘要: Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired bythis... 阅读全文
posted @ 2015-07-23 12:31 鸭子船长 阅读(205) 评论(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"]. 1 class ... 阅读全文
posted @ 2015-07-23 12:30 鸭子船长 阅读(155) 评论(0) 推荐(0) 编辑
摘要: Implement a basic calculator to evaluate a simple expression string.The expression string contains onlynon-negativeintegers,+,-,*,/operators and empty... 阅读全文
posted @ 2015-07-23 12:30 鸭子船长 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Given an integer array of sizen, find all elements that appear more than⌊ n/3 ⌋times. The algorithm should run in linear time and in O(1) space.Hint:H... 阅读全文
posted @ 2015-07-23 12:29 鸭子船长 阅读(196) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's tota... 阅读全文
posted @ 2015-07-23 12:28 鸭子船长 阅读(205) 评论(0) 推荐(0) 编辑
摘要: Given an integer, write a function to determine if it is a power of two.1 bool isPowerOfTwo(int n) {2 if(n<=0)3 return false;4 if(n&(n-1... 阅读全文
posted @ 2015-07-23 12:27 鸭子船长 阅读(145) 评论(0) 推荐(0) 编辑
摘要: Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:Given n = 13,Return 6... 阅读全文
posted @ 2015-07-23 12:26 鸭子船长 阅读(155) 评论(0) 推荐(0) 编辑
摘要: Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front o... 阅读全文
posted @ 2015-07-23 12:26 鸭子船长 阅读(148) 评论(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 /** 2 * Definition for singly-li... 阅读全文
posted @ 2015-07-23 12:25 鸭子船长 阅读(229) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedia: ... 阅读全文
posted @ 2015-07-23 12:24 鸭子船长 阅读(173) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to thedefinition of LCA on Wikipedia: “The lowest ... 阅读全文
posted @ 2015-07-23 12:23 鸭子船长 阅读(209) 评论(0) 推荐(0) 编辑