当前位置: 首页 > news >正文

C++笔试-剑指offer

剑指offer

文章目录

  • 剑指offer
    • 数组
      • [数组中重复的数据 ](https://leetcode.cn/problems/find-all-duplicates-in-an-array/description/)
        • 将元素交换到对应的位置
      • 二维数组中的查找
        • 二叉搜索树
      • 旋转数组的最小数字
        • 二分查找
      • 数组中出现次数超过一半的数字
        • 相互抵消
      • 连续子数组的最大和(二)
        • 动态规划
    • 链表
      • 从尾到头打印链表
        • 反转链表(双指针、递归)
        • 拓展:反转链表中间一部分
      • 删除链表的节点
      • 链表合并
      • 链表中倒数最后k个结点
        • 双指针思想
      • 复杂链表的复制
        • 哈希表
        • 在每个旧节点后加上新节点
      • 删除有序链表中重复的元素-I
        • 双指针思想
      • 删除链表中重复的结点
    • 二叉树
      • 二叉树的深度
        • 递归
      • 二叉树的最小深度
      • 二叉树的镜像
    • 队列、栈
      • 用两个栈实现队列
    • 动态规划
    • 跳台阶
        • DP(ACM模式)
        • 递归(ACM模式)

数组

数组中重复的数据

将元素交换到对应的位置
class Solution {
public:vector<int> findDuplicates(vector<int>& nums) {vector<int> result;for (int i = 0; i<nums.size();i++){while (nums[i] != nums[nums[i]-1]){swap(nums[i],nums[nums[i]-1]);}}for (int i = 0; i<nums.size();i++){if (nums[i]-1 != i){result.push_back(nums[i]);}}return result;}
};

时间复杂度O(n)

空间复杂度O(1)

二维数组中的查找

二叉搜索树
class Solution{
public:bool Find(int target, vector<vector><int> arr){if (arr.empty() || arr[0].empty()) return false;int i = 0;//行int j = arr.size()-1;//列while (i<=arr.size()-1 && j>=0){if (target == arr[i][j])return true;else if (tartget < arr[i][j])--j;else++i;}return false;}
}

类似于二叉搜索树:

1

旋转数组的最小数字

二分查找

最小值一定在右区域!

class Solution {
public:/*** 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可** * @param nums int整型vector * @return int整型*/int minNumberInRotateArray(vector<int>& nums) {int left = 0, right = nums.size()-1;int mid;while (left<right){mid = (left + right)/2;if (nums[left]<nums[right])//left一定在左区域或最低点,right一定在右区域,左区域的数一定大于等于右区域的数return nums[left];if (nums[mid] > nums[right])//mid在左区域,最小的数字在mid右边{left = mid + 1;}else if (nums[mid] == nums[right])//mid在重复元素{--right;}else //mid在右区域, 最小数字要么是mid要么在mid左边{right = mid;}}return nums[left];}
};

数组中出现次数超过一半的数字

相互抵消

用不同数字相互抵消的方法,最后留下来的一定是超过一半的数字

    int MoreThanHalfNum_Solution(vector<int>& numbers) {// write code hereint num = numbers[0];int count = 1;for (int i = 1; i<numbers.size(); ++i){if (count > 0){if (numbers[i]==num){++count;}else {--count;}}else //count = 0{num = numbers[i];count = 1;}}return num;}
};

1287. 有序数组中出现次数超过25%的元素

由于这题是升序,可以直接用步长判断,也可以用上题的步骤判断

连续子数组的最大和(二)

根据剑指offer自己想的,待优化:

int最大值INT_MAX,最小值INT_MIN

int的最小值可以写成0x8000000,最大值可以写成0x7FFFFFFF

class Solution {
public:vector<int> FindGreatestSumOfSubArray(vector<int>& arr) {// write code hereint result = 0x80000000;vector<int> vresult;vector<int> temp;int sum = 0;for (int i =0;i<arr.size();++i){if (sum<0)//如果和为负数,那么前一个和一定是从那个元素开始算的最大和了{temp.clear();temp.push_back(arr[i]);sum=arr[i];}else {sum+=arr[i];temp.push_back(arr[i]);}if (sum>=result){result = sum;vresult = temp;}}return vresult;}
};
动态规划
//只需要保存最大值时:
int res = nums[0];
for (int i = 1; i < nums.size(); i++) {if (nums[i - 1] > 0) nums[i] += nums[i - 1];if (nums[i] > res) res = nums[i];
}
return res;
//需要保存对应的子数组时:

求连续子数组的最大和(ACM模式)

#include <iostream>
#include <string>
#include <vector>
using namespace std;int main() {string str;cin>>str;//输入是个字符串int k =0;vector<int> numbers;while((k = str.find(',')) != str.npos){//注意输出的方法string temp = str.substr(0, k);numbers.push_back(stoi(temp));str = str.substr(k + 1);}numbers.push_back(stoi(str));int tempmax = 0;int result = 0x80000000;int sum = 0;for (int i =0; i<numbers.size();++i){if (sum<0){sum=numbers[i];}else {sum+=numbers[i];}result = max(sum,result);}if (result<0){result = 0;}printf("%d",result);
}
// 64 位输出请用 printf("%lld")

链表

从尾到头打印链表

利用栈先入后出的特点,很好解决

class Solution {
public:vector<int> printListFromTailToHead(ListNode* head) {stack<int> stk;vector<int> result;int value = 0;while (head!=nullptr){stk.push(head->val);head = head->next;}while (!stk.empty()){value = stk.top();result.push_back(value);stk.pop();}return result;}
};

时间复杂度O(n)

空间复杂度O(n)

反转链表(双指针、递归)

双指针:

class Solution {
public:vector<int> printListFromTailToHead(ListNode* head) {ListNode* preNode = nullptr;ListNode* curNode = head;while(curNode!=nullptr){ListNode* temp = curNode->next;curNode->next = preNode;preNode = curNode;curNode = temp;}vector<int> result;while(preNode!=nullptr){result.push_back(preNode->val);preNode = preNode->next;}return result;}
};

时间复杂度O(n)

空间复杂度O(1)

递归

class Solution {
public:vector<int> printListFromTailToHead(ListNode* head) {ListNode* newhead = ReverseList(head);vector<int> result;while (newhead!=nullptr){result.push_back(newhead->val);newhead = newhead->next;}return result;}ListNode* ReverseList(ListNode* head){if (head==nullptr || head->next==nullptr){return head;}ListNode* newhead = ReverseList(head->next);head->next->next = head;head->next = nullptr;return newhead;}
};

时间复杂度O(n)

空间复杂度O(n)

拓展:反转链表中间一部分

92. 反转链表 II - 力扣(LeetCode)

class Solution {
public:ListNode* reverseBetween(ListNode* head, int left, int right) {if (head->next==nullptr || left==right){return head;}ListNode* dummyhead = new ListNode(0);dummyhead->next = head;ListNode* preleftEdge = dummyhead;ListNode* leftEdge = head;ListNode* rightEdge = head;for(int i = 1; i<left;++i){preleftEdge = preleftEdge->next;leftEdge = preleftEdge->next;}for(int i = 1; i<right;++i){rightEdge = rightEdge->next;}ListNode* nextrightEdge = rightEdge->next;ListNode* leftNode = leftEdge;ListNode* firstNode = leftNode;ListNode* rightNode = leftNode->next;while (rightNode!=nextrightEdge){ListNode* temp = rightNode->next;rightNode->next = leftNode;leftNode = rightNode;rightNode = temp;}preleftEdge->next = leftNode;firstNode->next = nextrightEdge;return dummyhead->next;}
};

删除链表的节点

class Solution {
public:/*** 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可** * @param head ListNode类 * @param val int整型 * @return ListNode类*/ListNode* deleteNode(ListNode* head, int val) {// write code hereListNode* dummyhead = new ListNode(0);dummyhead->next = head;ListNode* pre = dummyhead;ListNode* cur = head;while (cur!=nullptr){if (cur->val==val){pre->next = cur->next;break;}else {cur = cur->next;pre = pre->next;}}return dummyhead->next;}
};

还有一种不需要知道前驱结点就可以“删除”链表结点的方法,前提是不能删除最后一个结点:

class Solution {
public:void deleteNode(ListNode* node) {node->val = node->next->val;node->next = node->next->next;}
};

链表合并

ACM模式的话要注意输入输出,然后要注意cur指针的更新

#include <iostream>
using namespace std;
struct ListNode
{int val;ListNode* next;ListNode(int val): val(val), next(nullptr){}
};int main() {int a;ListNode* dummyhead = new ListNode(0);ListNode* cur = dummyhead;ListNode* dummyhead1 = new ListNode(0);ListNode* cur1 = dummyhead1;ListNode* dummyhead2 = new ListNode(0);ListNode* cur2 = dummyhead2;while(cin>>a){ListNode* node = new ListNode(a);cur1->next = node;cur1 = cur1->next;if(cin.get()=='\n'){break;}}while(cin>>a){ListNode* node = new ListNode(a);cur2->next = node;cur2 = cur2->next;}cur1 = dummyhead1->next;cur2 = dummyhead2->next;while (cur1!=nullptr && cur2!=nullptr){if (cur1->val<=cur2->val){cur->next = cur1;cur1 = cur1->next;}else {cur->next = cur2;cur2 = cur2->next;}cur = cur->next;}if (cur1==nullptr){cur->next = cur2;}if (cur2==nullptr){cur->next = cur1;}cur = dummyhead->next;while (cur!=nullptr){printf("%d ",cur->val);cur = cur->next;}return 0;
}
// 64 位输出请用 printf("%lld")

链表中倒数最后k个结点

双指针思想

右指针指向左指针后k个元素,这样当右指针为最后一个节点后的元素时,左指针指向的就是所求元素

/*** struct ListNode {*	int val;*	struct ListNode *next;*	ListNode(int x) : val(x), next(nullptr) {}* };*/
class Solution {
public:/*** 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可** * @param pHead ListNode类 * @param k int整型 * @return ListNode类*/ListNode* FindKthToTail(ListNode* pHead, int k) {// write code hereif (pHead==nullptr){return nullptr;}ListNode* left = pHead;ListNode* right = left;for (int i =0; i<k;++i){if(right==nullptr){return nullptr;}right = right->next;  }while (right!=nullptr){right = right->next;left = left->next;}return left;}
};

复杂链表的复制

LCR 154. 复杂链表的复制 - 力扣(LeetCode)

哈希表

键为旧指针,值为新指针。第一次遍历时初始化键和值的label,第二次赋上next和random指针

class Solution {
public:Node* copyRandomList(Node* head) {if (head==nullptr){return nullptr;}unordered_map<Node*,Node*> mp;Node* cur = head;while (cur!=nullptr){Node* newNode = new Node(cur->val);mp[cur] = newNode;cur = cur->next;}cur = head;while (cur!=nullptr){mp[cur]->next = mp[cur->next];mp[cur]->random = mp[cur->random];cur = cur->next;}return mp[head];}
};
在每个旧节点后加上新节点

最后要记得把旧链表头结点断开连接

class Solution {
public:RandomListNode* Clone(RandomListNode* pHead) {if (pHead==nullptr){return nullptr;}//初始化nextRandomListNode* cur1 = pHead;while (cur1!=nullptr){RandomListNode* newNode = new RandomListNode(cur1->label);newNode->next = cur1->next;cur1->next = newNode;cur1 = cur1->next->next;}//赋值randomcur1 = pHead;RandomListNode* cur2 = pHead->next;while (cur1!=nullptr){if (cur1->random != nullptr){cur2->random = cur1->random->next;}cur1 = cur1->next->next;cur2 = cur2->next->next;}//拆分链表RandomListNode* newCloneHead = pHead->next;cur2 = newCloneHead;pHead->next = nullptr;while (cur2->next!=nullptr){cur2->next = cur2->next->next;cur2 = cur2->next;}cur2->next=nullptr;cur1 = pHead;cur2 = pHead->next;return newCloneHead;}
};

删除有序链表中重复的元素-I

双指针思想
    ListNode* deleteDuplicates(ListNode* head) {// write code hereif (head==nullptr){return nullptr;}ListNode* dummyhead = new ListNode(0);ListNode* left = dummyhead;ListNode* right = head;while(right!=nullptr){while (right->next!=nullptr && right->val==right->next->val){right = right->next;}left->next = right;left = left->next;right = right->next;}return dummyhead->next;}

删除链表中重复的结点

比前面多了再将right右移一步的动作,以及最后要把left指向nullptr

class Solution {
public:ListNode* deleteDuplication(ListNode* pHead) {if (pHead==nullptr){return nullptr;}ListNode* dummyhead = new ListNode(0);ListNode* left = dummyhead;ListNode* right = pHead;while(right!=nullptr){if(right->next!=nullptr && right->val==right->next->val){while (right->next!=nullptr && right->val==right->next->val){right = right->next;}right = right->next;continue;}left->next = right;left = left->next;right = right->next;}left->next = nullptr;return dummyhead->next;}
};

二叉树

二叉树的深度

递归

返回左子树和右子树深度的最大值加上一(后序遍历)

class Solution {
public:int TreeDepth(TreeNode* pRoot) {if (pRoot==nullptr){return 0;}return max(TreeDepth(pRoot->left),TreeDepth(pRoot->right))+1;}
};

二叉树的最小深度

111. 二叉树的最小深度 - 力扣(LeetCode)

和二叉树的(最大)深度的区别是,计算的是到叶子节点(左右孩子都为空)的最小深度,也用后序遍历实现

class Solution {
public:int minDepth(TreeNode* root) {if (root==nullptr){return 0;}if (root->left==nullptr && root->right!=nullptr){return minDepth(root->right)+1;}else if (root->right==nullptr && root->left!=nullptr){return minDepth(root->left)+1;}else{return min(minDepth(root->left),minDepth(root->right))+1;}}
};

二叉树的镜像

LCR 144. 翻转二叉树 - 力扣(LeetCode)

前序遍历

TreeNode* Mirror(TreeNode* pRoot) {// write code hereif (pRoot==nullptr) return pRoot;swap(pRoot->left,pRoot->right);Mirror(pRoot->left);Mirror(pRoot->right);return pRoot;}

后序遍历

TreeNode* Mirror(TreeNode* pRoot) {// write code hereif (pRoot==nullptr) return pRoot;Mirror(pRoot->left);Mirror(pRoot->right);swap(pRoot->left,pRoot->right);return pRoot;}

队列、栈

用两个栈实现队列

每当要pop的时候就获取stack2的最上面的元素,如果stack2为空,则将stack1依次出栈到stack2。这样stack2上面的就是最先push进去的元素,最底下是最新push进去的元素。

class Solution
{
public:void push(int node) {stack1.push(node);}int pop() {while (!stack2.empty()){int result = stack2.top();stack2.pop();return result;}while (!stack1.empty()){int temp = stack1.top();stack2.push(temp);stack1.pop();}int result = stack2.top();stack2.pop();return result;}private:stack<int> stack1;stack<int> stack2;
};

动态规划

跳台阶

DP(ACM模式)
#include <iostream>
#include <unordered_map>using namespace std;int main() {int a;cin>>a;unordered_map<int,int> dp;dp[0] = 1;dp[1] = 1;dp[2] = 2;if (a<=2){printf("%d",dp[a]);}else {for (int i=3;i<=a;i++){int temp = dp[2];dp[2] +=dp[1];dp[1] = temp;}printf("%d",dp[2]);}return 0;
}
// 64 位输出请用 printf("%lld")
递归(ACM模式)
#include <iostream>
using namespace std;int Jump(int num)
{if (num==0) return 1;if (num==1) return 1;if (num==2) return 2;return Jump(num-1) + Jump(num-2);
}int main() {int a;cin>>a;int result = Jump(a);printf("%d",result);return 0;
}
// 64 位输出请用 printf("%lld")

相关文章:

C++笔试-剑指offer

剑指offer 文章目录 剑指offer数组[数组中重复的数据 ](https://leetcode.cn/problems/find-all-duplicates-in-an-array/description/)将元素交换到对应的位置 二维数组中的查找二叉搜索树 旋转数组的最小数字二分查找 数组中出现次数超过一半的数字相互抵消 连续子数组的最大…...

Mac安装jadx并配置环境

jadx官网&#xff1a;GitHub - skylot/jadx: Dex to Java decompiler 第一种&#xff1a; 安装jadx命令&#xff1a; brew install jadx 启动jadx-gui命令&#xff1a; jadx-gui 可能遇到的问题&#xff1a; Downloading https://formulae.brew.sh/api/formula.jws.json** h…...

前端学习----css基础语法

CSS概述 CAscading Style Sheets(级联样式表) CSS是一种样式语言,用于对HTML文档控制外观,自定义布局等,例如字体,颜色,边距等 可将页面的内容与表现形式分离,页面内容存放在HTML文档中,而用于定义表现形式的CSS在一个.css文件中或HTML文档的某一部分 HTML与CSS的关系 HTM…...

超详解——python条件和循环——小白篇

目录 1. 缩进和悬挂else 2. 条件表达式 3. 和循环搭配的else 4. 可调用对象 总结&#xff1a; 1. 缩进和悬挂else 在Python中&#xff0c;代码块是通过缩进来表示的。条件判断和循环结构的代码块需要正确缩进。悬挂else指的是else子句和相应的if或循环在同一级别的缩进。 …...

DNS协议 | NAT技术 | 代理服务器

目录 一、DNS协议 1、DNS背景 2、DNS协议 域名 域名解析 二、NAT技术 1、NAT技术 2、NAPT技术 3、NAT技术的缺陷 三、代理服务器 1、正向代理服务器 2、反向代理服务器 一、DNS协议 域名系统&#xff08;Domain Name System&#xff0c;缩写&#xff1a;DNS&#…...

深入ES6:解锁 JavaScript 类与继承的高级玩法

个人主页&#xff1a;学习前端的小z 个人专栏&#xff1a;JavaScript 精粹 本专栏旨在分享记录每日学习的前端知识和学习笔记的归纳总结&#xff0c;欢迎大家在评论区交流讨论&#xff01; ES5、ES6介绍 文章目录 &#x1f4af;Class&#x1f35f;1 类的由来&#x1f35f;2 co…...

领域驱动设计:异常处理

一、异常的处理 异常处理是领域模型要考虑的一部分&#xff0c;原因在于模型的责任不可能无限大。在遇到自己处理能力之外的情况时&#xff0c;要采用异常机制报告错误&#xff0c;并将处理权转交。异常就是这样一种机制&#xff0c;某种程度上&#xff0c;它可以保证领域模型…...

网络网络层之(6)ICMPv6协议

网络网络层之(6)ICMPv6协议 Author: Once Day Date: 2024年6月2日 一位热衷于Linux学习和开发的菜鸟&#xff0c;试图谱写一场冒险之旅&#xff0c;也许终点只是一场白日梦… 漫漫长路&#xff0c;有人对你微笑过嘛… 全系列文章可参考专栏: 通信网络技术_Once-Day的博客-CS…...

《大道平渊》· 拾壹 —— 商业一定是个故事:讲好故事,员工奋发,顾客买单。

《大道平渊》 拾壹 "大家都在喝&#xff0c;你喝不喝&#xff1f;" 商业一定是个故事&#xff0c;人民群众需要故事。 比如可口可乐的各种故事。 可口可乐公司也只是被营销大师们&#xff0c; 作为一种故事载体&#xff0c;发挥他们的本领。 营销大师们开发故事…...

JavaScript 如何访问本地文件夹

在浏览器环境中的JavaScript&#xff08;通常指的是前端JavaScript&#xff09;由于安全限制&#xff0c;无法直接访问用户的本地文件或文件夹。这是为了防止恶意脚本访问并窃取用户的敏感数据。 但是&#xff0c;有几种方法可以间接地让用户选择并访问本地文件&#xff1a; 使…...

ArrayList顺序表简单实现

一、创建MyArrayList框架 1.1 MyArrayList 类中实现 arr 数组 import java.util.Arrays;public class MyArrayList {private int[] arr;private int usesize;private static final int P 10;public MyArrayList() {arr new int[P];} 在 MyArrayList 类内创建 arr 数组&…...

144、二叉树的前序递归遍历

题解&#xff1a; 递归书写三要素&#xff1a; 1&#xff09;确定递归函数的参数和返回值。要确定每次递归所要用到的参数以及需要返回的值 2&#xff09;确定终止条件。操作系统也是用栈的方式实现递归&#xff0c;那么如果不写终止条件或者终止条件写的不对&#xff0c;都…...

youtube 1080 分辨率 下载方式

YouTube 1080p Video Downloader 这张图像代表了Autodesk Maya中一个名为rocket_body_MAT的材质的着色器网络。下面是对节点及其连接的细分: 节点 place2dTexture12: 该节点用于控制2D纹理在表面上的位置映射。输出: Out UVrocket_body2.jpg: 该节点代表一个纹理文件,具体是…...

计算机网络ppt和课后题总结(下)

常用端口总结 计算机网络中&#xff0c;端口是TCP/IP协议的一部分&#xff0c;用于标识运行在同一台计算机上的不同服务。端口号是一个16位的数字&#xff0c;范围从0到65535。通常&#xff0c;0到1023的端口被称为“熟知端口”或“系统端口”&#xff0c;它们被保留给一些标准…...

测试基础12:测试用例设计方法-边界值分析

课程大纲 1、定义 经验发现&#xff0c;较多的错误往往发生在输入或输出范围的边界上&#xff0c;因为边界值是代码判断语句的点&#xff0c;一般容易出问题&#xff08;数值写错、多加或丢失等号、写错不等号方向…&#xff09;。所以增加对取值范围的边界数据的测试&#xff…...

AI大模型在健康睡眠监测中的深度融合与实践案例

文章目录 1. 应用方案2. 技术实现2.1 数据采集与预处理2.2 构建与训练模型2.3 个性化建议生成 3. 优化策略4. 应用示例&#xff1a;多模态数据融合与实时监测4.1 数据采集4.2 实时监测与反馈 5. 深入分析模型选择和优化5.1 LSTM模型的优势和优化策略5.2 CNN模型的优势和优化策略…...

【西瓜书】9.聚类

聚类任务是无监督学习的一种用于分类等其他任务的前驱过程&#xff0c;作为数据清洗&#xff0c;基于聚类结果训练分类模型 1.聚类性能度量&#xff08;有效性指标&#xff09; 分类任务的性能度量有错误率、精度、准确率P、召回率R、F1度量(P-R的调和平均)、TPR、FPR、AUC回归…...

使用jemalloc实现信号驱动的程序堆栈信息打印

使用jemalloc实现信号驱动的程序堆栈信息打印 本文介绍应用如何集成jemalloc&#xff0c;在接收到SIGUSR1信号10时打印程序的堆栈信息。 1. 编译jemalloc 首先&#xff0c;确保你已经编译并安装了启用prof功能的jemalloc。以下是ubuntu18.04上的编译步骤&#xff1a; git c…...

树的4种遍历

目录 树的四种遍历方式的总结 1. 前序遍历&#xff08;Pre-order Traversal&#xff09; 2. 中序遍历&#xff08;In-order Traversal&#xff09; 3. 后序遍历&#xff08;Post-order Traversal&#xff09; 4. 层序遍历&#xff08;Level-order Traversal 或 广度优先遍…...

深入探讨5种单例模式

文章目录 一、对比总览详细解释 二、代码1. 饿汉式2. 饱汉式3. 饱汉式-双检锁4. 静态内部类5. 枚举单例 三、性能对比 一、对比总览 以下是不同单例模式实现方式的特性对比表格。表格从线程安全性、延迟加载、实现复杂度、反序列化安全性、防反射攻击性等多个方面进行考量。 …...

国防科技大学计算机基础课程笔记02信息编码

1.机内码和国标码 国标码就是我们非常熟悉的这个GB2312,但是因为都是16进制&#xff0c;因此这个了16进制的数据既可以翻译成为这个机器码&#xff0c;也可以翻译成为这个国标码&#xff0c;所以这个时候很容易会出现这个歧义的情况&#xff1b; 因此&#xff0c;我们的这个国…...

【杂谈】-递归进化:人工智能的自我改进与监管挑战

递归进化&#xff1a;人工智能的自我改进与监管挑战 文章目录 递归进化&#xff1a;人工智能的自我改进与监管挑战1、自我改进型人工智能的崛起2、人工智能如何挑战人类监管&#xff1f;3、确保人工智能受控的策略4、人类在人工智能发展中的角色5、平衡自主性与控制力6、总结与…...

阿里云ACP云计算备考笔记 (5)——弹性伸缩

目录 第一章 概述 第二章 弹性伸缩简介 1、弹性伸缩 2、垂直伸缩 3、优势 4、应用场景 ① 无规律的业务量波动 ② 有规律的业务量波动 ③ 无明显业务量波动 ④ 混合型业务 ⑤ 消息通知 ⑥ 生命周期挂钩 ⑦ 自定义方式 ⑧ 滚的升级 5、使用限制 第三章 主要定义 …...

前端倒计时误差!

提示:记录工作中遇到的需求及解决办法 文章目录 前言一、误差从何而来?二、五大解决方案1. 动态校准法(基础版)2. Web Worker 计时3. 服务器时间同步4. Performance API 高精度计时5. 页面可见性API优化三、生产环境最佳实践四、终极解决方案架构前言 前几天听说公司某个项…...

Java如何权衡是使用无序的数组还是有序的数组

在 Java 中,选择有序数组还是无序数组取决于具体场景的性能需求与操作特点。以下是关键权衡因素及决策指南: ⚖️ 核心权衡维度 维度有序数组无序数组查询性能二分查找 O(log n) ✅线性扫描 O(n) ❌插入/删除需移位维护顺序 O(n) ❌直接操作尾部 O(1) ✅内存开销与无序数组相…...

【Redis技术进阶之路】「原理分析系列开篇」分析客户端和服务端网络诵信交互实现(服务端执行命令请求的过程 - 初始化服务器)

服务端执行命令请求的过程 【专栏简介】【技术大纲】【专栏目标】【目标人群】1. Redis爱好者与社区成员2. 后端开发和系统架构师3. 计算机专业的本科生及研究生 初始化服务器1. 初始化服务器状态结构初始化RedisServer变量 2. 加载相关系统配置和用户配置参数定制化配置参数案…...

【决胜公务员考试】求职OMG——见面课测验1

2025最新版&#xff01;&#xff01;&#xff01;6.8截至答题&#xff0c;大家注意呀&#xff01; 博主码字不易点个关注吧,祝期末顺利~~ 1.单选题(2分) 下列说法错误的是:&#xff08; B &#xff09; A.选调生属于公务员系统 B.公务员属于事业编 C.选调生有基层锻炼的要求 D…...

土地利用/土地覆盖遥感解译与基于CLUE模型未来变化情景预测;从基础到高级,涵盖ArcGIS数据处理、ENVI遥感解译与CLUE模型情景模拟等

&#x1f50d; 土地利用/土地覆盖数据是生态、环境和气象等诸多领域模型的关键输入参数。通过遥感影像解译技术&#xff0c;可以精准获取历史或当前任何一个区域的土地利用/土地覆盖情况。这些数据不仅能够用于评估区域生态环境的变化趋势&#xff0c;还能有效评价重大生态工程…...

.Net Framework 4/C# 关键字(非常用,持续更新...)

一、is 关键字 is 关键字用于检查对象是否于给定类型兼容,如果兼容将返回 true,如果不兼容则返回 false,在进行类型转换前,可以先使用 is 关键字判断对象是否与指定类型兼容,如果兼容才进行转换,这样的转换是安全的。 例如有:首先创建一个字符串对象,然后将字符串对象隐…...

站群服务器的应用场景都有哪些?

站群服务器主要是为了多个网站的托管和管理所设计的&#xff0c;可以通过集中管理和高效资源的分配&#xff0c;来支持多个独立的网站同时运行&#xff0c;让每一个网站都可以分配到独立的IP地址&#xff0c;避免出现IP关联的风险&#xff0c;用户还可以通过控制面板进行管理功…...