![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
面试算法
二伟在努力
这个作者很懒,什么都没留下…
展开
-
面试算法(每更两题):链表、队列、栈(一)
1.由链表存储两个数字,计算这两个数字的和 如图所示: 链表从头至尾:个位、十位、百位…… #include<iostream> typedef struct tagSNode{ int value; tagSNode* pNext; tagSNode(int v) : value(v), pNext(NULL){} }SNode; SNode *Add(SNode* pH...原创 2018-12-04 19:42:38 · 154 阅读 · 0 评论 -
面试算法(每更两题):链表、队列、栈(四)
7.检查括号是否匹配 bool IsLeftParenthese(char c){ return (c == '(') || (c == '[') || (c == '{'); } bool IsMatch(char left, char c){ if (left == '(') return c == ')'; if (left == '[') return c == ']'...原创 2018-12-12 19:42:52 · 207 阅读 · 0 评论 -
面试算法(每更两题):链表、队列、栈(二)
3.给定一个链表,两个整数m,n,m<n,翻转链表中m到n的元素 #include <iostream> using namespace std; typedef struct tagSNode{ int value; tagSNode* pNext; tagSNode(int v) : value(v), pNext(NULL){} }SNode; void Prin...原创 2018-12-07 09:45:42 · 158 阅读 · 0 评论 -
面试算法(每更两题):链表、队列、栈(三)
5.给定两个单向链表,计算两个链表的第一个公共节点,若没有公共节点,返回空。 int CalcLength(SNode *p){ int nLen = 0; while (p){ p = p->pNext; nLen++; } return nLen; } SNode *FindFirstSameNode(SNode *pA, SNode *pB){ pA = pA-&g...原创 2018-12-10 17:07:54 · 125 阅读 · 0 评论