![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
牛客剑指Offer
Swadtone
这个作者很懒,什么都没留下…
展开
-
验证IP地址
验证IP地址原创 2022-12-14 16:18:33 · 246 阅读 · 1 评论 -
比较版本号
比较版本号原创 2022-12-14 14:52:37 · 477 阅读 · 0 评论 -
把字符串转换成整数(atoi)
把字符串转换成整数(atoi)原创 2022-12-14 12:32:09 · 399 阅读 · 0 评论 -
旋转字符串
旋转字符串原创 2022-12-13 22:35:40 · 106 阅读 · 0 评论 -
压缩字符串(一)
压缩字符串(一)原创 2022-12-13 22:16:46 · 212 阅读 · 0 评论 -
字符串变形
字符串变形原创 2022-12-13 21:50:08 · 197 阅读 · 0 评论 -
数字字符串转化成IP地址
数字字符串转化成IP地址原创 2022-12-13 21:02:39 · 236 阅读 · 0 评论 -
按之字形顺序打印二叉树
tree原创 2022-08-28 23:02:15 · 327 阅读 · 0 评论 -
二叉树的深度
tree原创 2022-08-28 22:39:48 · 236 阅读 · 0 评论 -
【无标题】 合并两个排序的链表
链表原创 2022-08-28 20:31:25 · 67 阅读 · 0 评论 -
在二叉树中找到两个节点的最近公共祖先
思路:深度遍历以所求节点为终止节点的路径,判断两个路径的交点/** * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */class Solution {public: /** * * @param root TreeNode类 * @param o1 int整型 * @param o2 int整型原创 2021-09-13 19:11:12 · 140 阅读 · 0 评论 -
有效的括号序列
stack<char> c_stack; for(int i = 0;i<s.length();i++){ if(s[i] == '('){ c_stack.push(')'); } else if(s[i] == '['){ c_stack.push(']'); } else if(s[..原创 2021-09-09 21:26:43 · 52 阅读 · 0 评论 -
5.用两个栈实现队列
class Solution{public: void push(int node) { while(!stack1.empty()){ stack2.push(stack1.top()); stack1.pop(); } stack2.push(node); while(!stack2.empty()){ stack1.push(stack2.top());原创 2021-08-23 21:58:21 · 46 阅读 · 0 评论 -
4.重建二叉树
注:没有中序是无法构造的/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: TreeNode* reConstructBinar原创 2021-08-23 21:50:50 · 44 阅读 · 0 评论 -
3. 从尾到头打印链表
从头到尾打印,然后逆序 或者利用栈的先进后出vector<int> printListFromTailToHead(ListNode* head) { vector<int> res; while(head){ res.push_back(head->val); head = head->next; } reverse(res.begin(), res.end原创 2021-08-23 21:29:11 · 56 阅读 · 0 评论 -
2.替换空格
string replaceSpace(string s) { // write code here string res = ""; for(int i = 0;i<s.size();i++){ if(s[i] != ' '){ res += s[i]; } else{ res += "%20";原创 2021-08-23 21:25:52 · 47 阅读 · 0 评论 -
1. 二维数组中的查找
思路(1)每一行有序,对每一行二分查找bool Find(int target, vector<vector<int> > array) { // 每一行有序 int row = array.size(); int col = array[0].size(); for(int i = 0;i<row;i++){ int low = 0; int high = ar原创 2021-08-23 21:21:28 · 53 阅读 · 0 评论