剑指offer部分题目整理
来源:互联网 发布:香蕉网络电视免费 编辑:程序博客网 时间:2024/05/21 09:28
以下为本人做t归整的个人觉得比较易懂的代码
#include <list>#include <vector>#include <iostream>#include <map>#include <stack>using namespace std;struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { }};class Solution {public: bool Find(int target, vector<vector<int> > array) {/*二维数组查找*/ map<int, bool>mp; for (int i = 0;i < array.size();i++) { for (int j = 0;j < array[i].size();j++) { mp[array[i][j]] = true; } } return mp.find(target) != mp.end(); } vector<int> printListFromTailToHead(ListNode* head) /*尾头打印链表*/ { vector<int> res; stack<int> s; if (head == NULL) return res; ListNode* p = head; while (p != NULL) { s.push(p->val); p = p->next; } while (!s.empty()) { res.push_back(s.top()); s.pop(); } return res; }};int main(){ Solution s1; /*vector<vector<int> > a(2,vector<int>(2)); a[0][0] = 1; a[0][1] = 2; a[1][0] = 3; a[1][1] = 4;*/ //cout << s1.Find(4, a)<<endl; /*ListNode L1(0); ListNode L2(5); ListNode L3(6); L1.next = &L2; L2.next = &L3; vector<int> a = s1.printListFromTailToHead(&L1); for (int i=0;i<a.size();i++) { cout << a[i] << " "; }*/ getchar(); return 0;}
阅读全文
1 0
- 剑指offer部分题目整理
- 剑指offer重要题目整理总结
- 剑指offer算法编程题目部分汇总(解法略)
- 部分题目整理:大数据
- 剑指offer题目集
- 剑指offer题目记录
- 剑指offer题目概括
- 剑指offer题目
- 【剑指offer】题目4
- 【剑指offer】题目10
- 剑指offer题目分类
- 剑指offer题目1
- 剑指offer第七部分
- 剑指offer-算法整理
- 剑指offer题目练习一
- 剑指offer题目1-10
- 剑指offer题目汇总(一)
- 剑指offer题目汇总(二)
- 求阶乘以及求各项阶乘和问题
- 2017 ACM-ICPC 亚洲区-banana
- 博客大转战
- 系统管理员的修炼宝典
- Python内置函数详解
- 剑指offer部分题目整理
- ASCII码对照表
- Android 读取本地图片的缩略图
- 静态,构造方法和super
- 利用pyinstaller打包python3程序
- localStorage使用总结
- Android 使用集成环信EaseUI
- 理解原码、反码和补码-------带例子详解
- redis 实例化以及ping 的操作