- 博客(7)
- 收藏
- 关注
转载 C++输入输出
加速C++输入输出流https://www.cnblogs.com/PrayG/p/5749832.htmlcin,cout之所以效率低,是因为先把要输出的东西存入缓冲区,再输出,导致效率降低,而这段语句可以来打消iostream的输入输出缓存,可以节省许多时间,使效率与scanf与printf相差无几,还有应注意的是scanf与printf使用的头文件应是stdio.h而不是iostream。然后尽量用"\n"而不是endlsync_with_stdio#include <iostream
2020-09-07 09:24:25
72
原创 树相关知识
树的结构定义/** Definition for a binary tree node.*/* struct TreeNode { * int val;* TreeNode *left;* TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; 二叉树二叉树的四种遍历:优秀解释1)前序遍历//法一:递归法class Solution {p.
2020-08-30 16:36:26
143
原创 回溯法相关题目
回溯法(back tracking)用回溯法解问题时,应明确定义问题的解空间。问题的解空间至少包含问题的一个(最优)解。22.括号生成:mediumclass Solution {public: void backtrack(vector<string>& res, string s, int open, int close, int n){//剪枝操作 if (open > n || close > n ||
2020-08-29 22:02:52
196
原创 递归
递归LeetCode递归题目合并两个有序链表:easyclass Solution {public: ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) { if (l1 == NULL) return l2; if (l2 == NULL) return l1; if (l1->val <= l2->val){ l1->
2020-08-28 09:01:39
70
原创 LeetCode题目
链表操作遇到链表问题先在纸上画出结构LeetCode原题:复杂链表的复制解题思路一使用哈希表将新旧链表一一对应;根据原链表的next和random指针来构建新链表的next和random指针class Solution {public: Node* copyRandomList(Node* head) { if (head == NULL) return NULL; unordered_map<Node*, Node*> mp;
2020-08-27 20:02:46
95
原创 链表
链表知识点链表定义//Definition for singly-linked list. struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} };
2020-08-27 11:05:59
84
转载 hash表
hash表相关文字引用该blog头文件#include <unordered_map>定义与初始化unordered_map<int,string> unomap;unordered_map<int,string> unomap = {{1,"dd"},{2,"ssss"}};打印查找for(auto x: unomap){ cout<<unomap[x.first]<<endl; cout<<x
2020-08-26 10:55:34
92
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人