摘要: 题目 剑指 Offer 11. 旋转数组的最小数字 代码 算法一 class Solution { public: int minArray(vector<int>& numbers) { int res = numbers[0]; for(int i = 1; i < numbers.size() 阅读全文
posted @ 2022-04-19 15:39 当惜 阅读(23) 评论(0) 推荐(0)
摘要: 题目 剑指 Offer 10- II. 青蛙跳台阶问题 代码 class Solution { public: int numWays(int n) { int a = 1, b = 1; while(n--) { int c = (a + b) % 1000000007; a = b; b = c 阅读全文
posted @ 2022-04-18 11:22 当惜 阅读(21) 评论(0) 推荐(0)
摘要: 题目 剑指 Offer 10- I. 斐波那契数列 代码 class Solution { public: int fib(int n) { int a = 0, b = 1; while(n--) { int c = (a + b) % 1000000007; a = b; b = c; } re 阅读全文
posted @ 2022-04-18 11:19 当惜 阅读(18) 评论(0) 推荐(0)
摘要: 题目 剑指 Offer 09. 用两个栈实现队列 代码 class CQueue { public: stack<int> stk, cache; CQueue() { } void copy(stack<int> &a, stack<int> &b) { while(a.size()) { b.p 阅读全文
posted @ 2022-04-18 09:57 当惜 阅读(21) 评论(0) 推荐(0)
摘要: 题目 剑指 Offer 07. 重建二叉树 解析 确定中序遍历中头节点位置index 计算左子树长度size = index - inl,inl为中序遍历的起点 构建左子树 前序遍历位置:[prel + 1, prel + size] 中序遍历位置:[inl, index - 1] 构建右子树 前序 阅读全文
posted @ 2022-04-17 20:56 当惜 阅读(16) 评论(0) 推荐(0)
摘要: 题目 剑指 Offer 06. 从尾到头打印链表 代码 递归 class Solution { public: vector<int> reversePrint(ListNode* head) { if(!head) return {}; auto res = reversePrint(head-> 阅读全文
posted @ 2022-04-17 16:36 当惜 阅读(15) 评论(0) 推荐(0)
摘要: 题目 剑指 Offer 05. 替换空格 代码 class Solution { public: string replaceSpace(string s) { string res; for(auto x : s) { if(x == ' ') res += "%20"; else res += 阅读全文
posted @ 2022-04-17 16:21 当惜 阅读(17) 评论(0) 推荐(0)
摘要: 题目 剑指 Offer 04. 二维数组中的查找 代码 class Solution { public: bool findNumberIn2DArray(vector<vector<int>>& matrix, int target) { if(matrix.empty()) return fal 阅读全文
posted @ 2022-04-17 16:12 当惜 阅读(17) 评论(0) 推荐(0)
摘要: 题目 剑指 Offer 03. 数组中重复的数字 代码 class Solution { public: int findRepeatNumber(vector<int>& nums) { for(int i = 0; i < nums.size(); i++) { while(nums[nums[ 阅读全文
posted @ 2022-04-17 11:25 当惜 阅读(18) 评论(0) 推荐(0)
摘要: 下载 https://tomcat.apache.org/ 环境配置 此电脑-属性-高级系统设置-环境变量 新建 JRE_HOME-(jdk目录下的jre文件夹) 进入Tomcat目录下的bin目录,cmd,将startup.bat拖入cmd 乱码 进入Tomcat目录下的conf目录,打开logg 阅读全文
posted @ 2022-04-12 20:09 当惜 阅读(37) 评论(0) 推荐(0)