
算法面试题集
_Summer-
Just do it!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Remove Duplicates from Sorted Array
单词: duplicate相同的数 Sort有序 Array数组思路: 1.Allocate extra space for another array#include <iostream>#include <vector>using namespace std;class SortedArray{public: void Print(vector<int> &nums原创 2016-03-18 11:31:44 · 181 阅读 · 0 评论 -
Remove Duplicates from Sorted Array II
思路:加入一个变量来记录元素出现的次数方法一:class A{public: int Remove(int *a,int len) { if(a==NULL||len<0) return 0; if(len<=2) return len; int index=2; f原创 2016-03-18 15:58:44 · 184 阅读 · 0 评论 -
Add Two Numbers
题意: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a原创 2016-03-18 23:56:50 · 182 阅读 · 0 评论 -
Reverse Linked List II
说明: Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->nullptr, m = 2 and n = 4, return 1->4->3->2->5->nullptr. Note: Given m, n satisfy t原创 2016-03-20 00:14:47 · 201 阅读 · 0 评论 -
Partition List
单词:partition 分割 说明: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of原创 2016-03-20 23:37:41 · 214 阅读 · 0 评论 -
Remove Duplicates from Sorted List
说明: Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. 代码:/*******************原创 2016-03-21 12:41:59 · 194 阅读 · 0 评论 -
Binary Tree Preorder Traversal
单词: Preorder 前序,先序 Traversal 遍历 思路: 栈容器 先将根压入栈,用节点保存头元素,当栈容器不为空时 //遍历 while(!B.empty()) { //节点保存头元素; p=B.top(); //将头元素的数据压入vector容器; result.push_back(p->data); //头元素出栈;原创 2016-03-24 22:21:14 · 229 阅读 · 0 评论 -
Binary Tree Inorder Traversal
单词: inorder 中序 Traversal 遍历代码:#include <iostream>#include<vector>#include<stack>using namespace std;//数的结构体typedef struct _BiNode{ //数据 int data; //左孩子 struct _BiNode* lChild;原创 2016-03-25 23:22:03 · 163 阅读 · 0 评论