求职-0-
卖萌书生
这个作者很懒,什么都没留下…
展开
-
[面试准备】数据结构--链表
#include using namespace std;//链表节点定义template struct SLNode{ T data; SLNode* next; SLNode(SLNode* nextnode = NULL){ next = nextnode; } SLNode(const T& item,SLNode* nextnode = NULL){ da原创 2014-08-02 19:20:40 · 539 阅读 · 0 评论 -
【面试准备】list
STL中list的使用:STL中的list就是一双向链表,可高效地进行插入删除元素。现总结一下它的操作。文中所用到两个list对象c1,c2分别有元素c1(10,20,30) c2(40,50,60)。还有一个list::iterator citer用来指向c1或c2元素。list对象的声明构造():A. listc0;转载 2014-09-02 18:03:12 · 589 阅读 · 0 评论 -
【面试准备】letcode-Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to原创 2014-09-02 20:39:02 · 463 阅读 · 0 评论 -
【面试准备】letcode—sort list
Sort a linked list in O(n log n) time using constant space complexity./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int原创 2014-09-02 16:16:57 · 399 阅读 · 0 评论 -
【面试准备】letcode-Linked List Cycle |
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: bo原创 2014-09-02 21:47:34 · 405 阅读 · 0 评论 -
【面试准备】letcode—LRU
#include #include #include using namespace std;struct CacheNode{ int key; int value; CacheNode(int x,int y):key(x),value(y){}};class LRUCache{public: LRUCache(int capacity){ size = capa原创 2014-09-02 18:36:57 · 421 阅读 · 0 评论 -
【面试准备】letcode-Binary Tree Preorder Traversal
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti原创 2014-09-02 19:41:34 · 415 阅读 · 0 评论 -
【面试准备】letcode-Linked List Cycle ||
快慢指针遍历/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: List原创 2014-09-02 21:40:27 · 400 阅读 · 0 评论 -
找出数组中只出现一次的2个数
1. 首先数组中所有元素依次异或,因为相同的元素异或得到0,所以最终的答案就等于那2个唯一的元素a^b的值。2. 因为a,b不同,所以异或得到的答案肯定是不等于0的,那么我们就找到a^b的二进制表示中第一个为1的位,假如是第k位。而a,b两个数在第k位上是不同的,一个为0,一个为13. 接下来我们将第k位是1的分成一组,第k位是0的分成一组,如果2个元素相同,那么他们第k位肯定是一原创 2014-09-03 16:01:02 · 388 阅读 · 0 评论 -
【面试准备】letcode-Single Number
一个与本身异或之后为0;原创 2014-09-03 15:44:17 · 452 阅读 · 0 评论 -
const
http://blog.csdn.net/Eric_Jo/article/details/4138548转载 2014-09-16 22:57:45 · 408 阅读 · 0 评论 -
【面试准备】letcode-Tow Sum
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe原创 2014-09-03 09:13:02 · 526 阅读 · 0 评论 -
【面试准备】letcode-Copy List with Random Pointer
/** * Definition for singly-linked list with a random pointer. * struct RandomListNode { * int label; * RandomListNode *next, *random; * RandomListNode(int x) : label(x), next(NULL),原创 2014-09-03 15:34:47 · 411 阅读 · 0 评论 -
【面试准备】letcode-Word Break
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet"原创 2014-09-03 10:19:24 · 583 阅读 · 0 评论 -
寻找包含给定字符集合的最小子串
#include #include using namespace std;string min_str(string str1,string str2){ if(str1.size() == str2.size() ) { return min(str1,str2); } return str1.size() > str2.size()转载 2014-09-17 17:35:46 · 734 阅读 · 0 评论 -
【面试准备】八皇后问题
#include using namespace std;#define Slove_num 8int seat[Slove_num];bool ok(int n);int count = 0;void queen(int n){ if(n == Slove_num){ for(int i = 0;i < n; ++i){ cout<<"("<<i<<","<<seat原创 2014-09-04 16:12:15 · 444 阅读 · 0 评论 -
红黑树
http://baike.baidu.com/view/133754.htm?fr=aladdin转载 2014-09-17 20:24:14 · 490 阅读 · 0 评论 -
【面试准备】letcode-Binary Tree Postorder Traversal
后序遍历二叉树,堆栈,记录一下当前输出的节点;原创 2014-09-02 19:06:23 · 430 阅读 · 0 评论 -
【面试准备】vector
http://blog.csdn.net/phoebin/article/details/3864590原创 2014-09-02 18:50:50 · 379 阅读 · 0 评论 -
【面试准备】letcode-Insertion Sort List
Sort a linked list using insertion sort./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */原创 2014-09-02 16:41:15 · 521 阅读 · 0 评论 -
【面试准备】数据结构-二叉树
#include using namespace std;templateclass BinTreeNode{private: BinTreeNode *left,*right; T data;public: BinTreeNode(BinTreeNode *lptr,BinTreeNode *rptr,T& item){ left = lptr; right = r原创 2014-08-02 19:25:36 · 464 阅读 · 0 评论 -
【面试准备】C语言printf输出格式
%a 浮点数、十六进制数字和p-记数法(C99)%A 浮点数、十六进制数字和p-记法(C99)%c 一个字符 %d 有符号十进制整数 %e 浮点数、e-记数法%E 浮点数、E-记数法%f 浮点数、十进制记数法 %g 根据数值不同自动选择%f或%e.%G 根据数值不同自动选择%f或%e.%i原创 2014-08-02 19:29:21 · 408 阅读 · 0 评论 -
【面试准备】C文件操作函数
C语言文件操作函数大全clearerr(清除文件流的错误旗标)相关函数 feof表头文件 #include定义函数 void clearerr(FILE * stream);函数说明 clearerr()清除参数stream指定的文件流所使用的错误旗标。返回值 fclose(关闭文件)相关函数 close,fflush,fopen,setbuf表头文件 #i转载 2014-08-02 19:27:04 · 436 阅读 · 0 评论 -
【面试准备】数据结构—树
左孩子,右兄弟,二叉树存储-0-原创 2014-08-05 09:29:28 · 444 阅读 · 0 评论 -
【面试准备】数据结构-Huffman树
#include using namespace std;//Hanfuman树节点类templateclass HuffmanNode {private: HuffmanNode *left, *right; T data; int weight;public: HuffmanNode() { ; } HuffmanNode(HuffmanNode* L, Huff原创 2014-08-05 14:53:15 · 508 阅读 · 0 评论 -
【面试准备】数据结构-堆栈
#include using namespace std;templateclass AStack{private: int size; T* stackArray; int top;public: AStack(int MaxStackSize){ size = MaxStackSize; stackArray = new T[MaxStackSize]; top原创 2014-08-02 19:23:56 · 440 阅读 · 0 评论 -
【面试准备】数据结构-队列
#include using namespace std;template struct SLNode{ T data; SLNode* next; SLNode(SLNode* nextnode = NULL){ next = nextnode; } SLNode(const T& item,SLNode* nextnode = NULL){ data = item原创 2014-08-02 19:22:30 · 389 阅读 · 0 评论 -
【面试准备】快排
#include using namespace std;void Quicksort(int e[],int first,int end){ int i = first, j = end; int temp = e[i]; while(i<j){ while(i<j && temp<=e[j]){ j--; } e[i] = e[j]; while(i<j &原创 2014-09-01 19:57:08 · 416 阅读 · 0 评论 -
【面试准备】堆排
#include using namespace std;void AdjastHeapSort(int a[],int i,int n){//调整节点i,数组共有n个节点 if(n == 1||i >(n-2)/2){ return ; } int iLeft = 2*i+1;//i从0开始 int iRight = 2*i+2; if(iRight<=n-1){ if原创 2014-09-01 22:04:49 · 464 阅读 · 0 评论 -
【面试准备】最长公共子序列
#include #include using namespace std;#define MAXLEN 100void LCSLength(char* x, char *y, int m, int n, int c[][MAXLEN], int b[][MAXLEN]) {//c[][]记录x[i]与y[i]的LCS长度;b[][]记录c[i][j]是通过哪一个子问题的值求得的以决原创 2014-09-01 19:06:59 · 359 阅读 · 0 评论 -
【面试准备】字符串反序
#include #include #include using namespace std;void reverseWords(string &s) { string a[s.length()]; int j = 0; int aa = 0; int i = 0; char *w = (char*) ma原创 2014-09-02 09:37:34 · 435 阅读 · 0 评论 -
【面试准备】letcode-Evaluate Reverse Polish Notation
Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9 ["4", "13", "5", "/", "+"] -> (4 + (13原创 2014-09-02 11:00:58 · 401 阅读 · 0 评论 -
【面试准备】map
Map是c++的一个标准容器,她提供了很好一对一的关系,在一些程序中建立一个map可以起到事半功倍的效果,总结了一些map基本简单实用的操作!1. map最基本的构造函数; mapmapstring; mapmapint; mapmapstring; mapmapchar; mapmapchar; mapmapint转载 2014-09-02 14:24:04 · 355 阅读 · 0 评论 -
TCP三次握手及四次挥手
http://www.cnblogs.com/hnrainll/archive/2011/10/14/2212415.html转载 2014-09-15 18:05:17 · 401 阅读 · 0 评论 -
【面试准备】求字符串中最长的重复子串
#include #include using namespace std;void substr(char *a) //统计数组a中重复出现的最长的子序列 { int n; for (n = 0; a[n] != '\0'; ++n) ; int count = 1; for (int len = n - 1; len > 0; --len) //len:子串的长度原创 2014-09-02 08:30:29 · 462 阅读 · 0 评论 -
【面试准备】letcode—Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.#include #include #include using namespace std;struct Point{ int x; int y; Point(): x(0),原创 2014-09-02 14:50:47 · 389 阅读 · 0 评论 -
东北大学考研二叉树相关试题
设t为一颗二叉树的根节点地址指针,设计一个非递归的算法把二叉树中每个节点的左右孩子位置交换原创 2014-11-25 00:15:27 · 3600 阅读 · 1 评论