STL标准模板库
ojshilu
https://github.com/lucky521
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Anagrams 变位词
Anagrams 可以翻译为变位词,对于英语来说一个英文单词的Anagrams,是把单词的字母顺序作调整从而变成另外的一个单词。还有一个中文的称呼叫做兄弟字符串。题目源自于leetcode。题目:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will原创 2013-12-15 16:54:57 · 1581 阅读 · 0 评论 -
标准模板库的空间配置器 STL's allocator
标准模板库中利用空间配置器来在幕后管理内存空间,有下面两种空间配置器。一种是标准的空间配置器std:allocator一种是高级的空间配置器std:alloc原创 2014-05-04 22:38:26 · 1125 阅读 · 0 评论 -
寻找最长重复子串/子数组 Longest Repeated Sequence
1,c[]是作为输入的字符串。a[]这个指针数组中的每个元素都是指向输入字符串的一个后缀子串的指针。后缀子串就是从输入字符串的某一个字符开始到字符串结尾所构成的子串。对于一个长度为n的字符串,就会有n个后缀子串(输入串本身也算是一个)。2,将这n个后缀子串排序。按照字母表顺序排序后,含有重复子串的后缀子串就会挨在一起。逐次比较相邻的两个后缀子串进行匹配,看他们的匹配长度。选出匹配长度最原创 2013-07-17 22:32:50 · 1369 阅读 · 2 评论 -
二叉树中增加next指针 Populating Next Right Pointers in Each Node
题目源自于leetcode。题目:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to原创 2013-11-06 20:58:02 · 1398 阅读 · 0 评论 -
图的深拷贝 Clone Graph
问题:Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors思路:图的复制问题、克隆问题。给你的只是图的冰山一角,就让你拷贝整张图。第一步,先遍历原图。把所有结点拿到手,构造一个邻接表头。第二步,根据原图的邻接表头,重建一个新的邻接表头。第三步,原创 2014-03-01 22:35:42 · 2557 阅读 · 0 评论 -
多种括号的匹配 Valid Parentheses
题目源自于Leetcode。题目:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{原创 2013-10-27 15:21:09 · 1313 阅读 · 0 评论 -
无序数组中找出和为N的两个数 Two Sum
如果是有序数组,很简单。两头指针往中间相遇即可。因此对于无序数组,排序即可。唯一的麻烦题目要求的:要返回两个数在排序之前原数组里的序号。因此我需要在排序时也要保留原来的序列号。这里主要是以前不写STL的程序。这里用到vector。pair。sort。vector常用到的vector.size()表示当前vector里的数据个数。初始化vector时用 vector v;原创 2013-09-30 14:20:52 · 4346 阅读 · 0 评论 -
在无序序列中找出最长的连续序列 Longest Consecutive Sequence
问题:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1,原创 2014-03-03 22:23:30 · 1801 阅读 · 0 评论
分享