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

东莞网站搭建哪里好如何优化关键词排名到首页

东莞网站搭建哪里好,如何优化关键词排名到首页,南京网站建设优化,画册设计理念和设计思路1--环形链表II 主要思路: 快慢指针,快指针每次走两步,慢指针每次走一步; 第一次相遇时,假设慢指针共走了 f 步,则快指针走了 2f 步; 假设起点到环入口结点的长度为 a(不包括入口结点…

1--环形链表II

主要思路:

        快慢指针,快指针每次走两步,慢指针每次走一步;

        第一次相遇时,假设慢指针共走了 f 步,则快指针走了 2f 步;

        假设起点到环入口结点的长度为 a(不包括入口结点),环的结点数为 b;快指针比慢指针多走的步数肯定全在环中,则有 2f - f = f = nb;则慢指针共走了 nb 步;

        由于慢指针共走了 nb 步,而起点到环入口结点的步数为 a,则实际慢指针在环内走了 nb - a 步;

        此时让慢指针从起点重新出发走 a 步,每次走 1 步;快指针从相遇的地方出发,每次也走 1 步,快慢指针必然在环入口结点相遇;因此快指针相当于也走了 a 步,恰好与 nb - a 步互补,构成完整圈数的 nb 环;

#include <iostream>
#include <vector>struct ListNode {int val;ListNode *next;ListNode(int x) : val(x), next(NULL) {}
};class Solution {
public:ListNode *detectCycle(ListNode *head) {if(head == nullptr) return head;ListNode *slow = head;ListNode *fast = head;while(fast != NULL && fast->next != NULL){fast = fast->next->next;slow = slow->next;if(fast == slow) break; // 第一次相遇}if(fast == NULL || fast->next == NULL) return NULL; // 没有环// 从头开始走slow = head;while(slow != fast){slow = slow->next;fast = fast->next;}// 第二次相遇就是环的入口return slow;}
};int main(int argc, char *argv[]) {// head = [3, 2, 0, -4], pos = 1ListNode *Node1 = new ListNode(3);ListNode *Node2 = new ListNode(2);ListNode *Node3 = new ListNode(0);ListNode *Node4 = new ListNode(-4);Node1->next = Node2;Node2->next = Node3;Node3->next = Node4;Node4->next = Node2;Solution S1;ListNode* res = S1.detectCycle(Node1);if(res != nullptr) std::cout << res->val << std::endl;else std::cout << "nullptr" << std::endl;return 0;
}

2--LRU缓存

主要思路:

        基于双向链表和哈希表;

        访问元素时,若元素不存在则返回;若元素存在,则将元素记录,并将元素移动到双向链表头部;(确保访问热度最高的元素放在双向链表头部,访问热度最低的元素放在双向链表尾部);

        插入元素时,若元素不存在:当容量已满时,先移除双向链表尾部的元素,再将新元素插入到双向链表头部;若元素存在,则取出元素并更新元素的值,将更新后的元素插入到双向链表头部;

#include <iostream>
#include <unordered_map>class LRUCache {
public:struct ListNode{ListNode(int key, int val){this->key = key;this->val = val;}ListNode* pre = nullptr;ListNode* next = nullptr;int val = 0;int key = 0;};LRUCache(int capacity) {this->cap = capacity; // 容量head = new ListNode(-1, -1);tail = new ListNode(-1, -1);head->next = tail;tail->pre = head;}int get(int key) {if(hash.count(key) == 0) return -1; // 元素不存在ListNode* ptr = hash[key]; // 取出元素remove(ptr); // 从双向链表中删除元素insert(ptr); // 将元素插入到双向链表头部return ptr->val; // 返回元素的值}void put(int key, int value) {if(hash.count(key) == 0){ // 元素不存在if(hash.size() == cap){ // 容量已满ListNode* ptr = tail->pre;remove(ptr); // 去除尾部节点hash.erase(ptr->key);delete(ptr);}ListNode* new_node = new ListNode(key, value); // 新建节点insert(new_node); // 插入新节点到头部hash[new_node->key] = new_node;return;}else{ // 元素存在ListNode* ptr = hash[key]; // 取出元素ptr->val = value; // 更新元素remove(ptr); // 先删除元素insert(ptr); // 再将元素插入到头部return;}}void remove(ListNode* ptr){// 取出前驱和后驱元素ListNode* a = ptr->pre;ListNode* b = ptr->next;// 更新前驱和后驱元素的指向a->next = b;b->pre = a;ptr->pre = ptr->next = nullptr;}void insert(ListNode* ptr){ListNode* tmp = head->next; // 头指针的下一个元素// 将元素插入到双向链表头部ptr->pre = head;head->next = ptr;ptr->next = tmp;tmp->pre = ptr;}
private:int cap = 0; // 容量std::unordered_map<int, ListNode*> hash; // 哈希表ListNode* head; // 双向链表哨兵头节点ListNode* tail; // 双向链表哨兵尾节点
};int main(int argc, char argv[]){return 0;
}


文章转载自:
http://chabouk.fwrr.cn
http://obliging.fwrr.cn
http://hesperus.fwrr.cn
http://outing.fwrr.cn
http://flattop.fwrr.cn
http://pompadour.fwrr.cn
http://cotentin.fwrr.cn
http://nota.fwrr.cn
http://passman.fwrr.cn
http://dipsas.fwrr.cn
http://unapproachable.fwrr.cn
http://octan.fwrr.cn
http://expectancy.fwrr.cn
http://susceptible.fwrr.cn
http://superheat.fwrr.cn
http://maymyo.fwrr.cn
http://monoculture.fwrr.cn
http://malajustment.fwrr.cn
http://easily.fwrr.cn
http://wander.fwrr.cn
http://rapine.fwrr.cn
http://interoceanic.fwrr.cn
http://chutnee.fwrr.cn
http://wirelike.fwrr.cn
http://unrelatable.fwrr.cn
http://podiatrist.fwrr.cn
http://deterrence.fwrr.cn
http://cryptobiote.fwrr.cn
http://miraculin.fwrr.cn
http://valeric.fwrr.cn
http://fluorination.fwrr.cn
http://cement.fwrr.cn
http://playground.fwrr.cn
http://outlier.fwrr.cn
http://metabiology.fwrr.cn
http://mongrel.fwrr.cn
http://amen.fwrr.cn
http://bulhorn.fwrr.cn
http://rejuvenescence.fwrr.cn
http://jinker.fwrr.cn
http://antebrachium.fwrr.cn
http://neptunism.fwrr.cn
http://abhorrent.fwrr.cn
http://pepperbox.fwrr.cn
http://balliol.fwrr.cn
http://ladanum.fwrr.cn
http://favorably.fwrr.cn
http://mughul.fwrr.cn
http://philter.fwrr.cn
http://mycophile.fwrr.cn
http://violin.fwrr.cn
http://qingdao.fwrr.cn
http://morality.fwrr.cn
http://endocytic.fwrr.cn
http://flitter.fwrr.cn
http://cuculliform.fwrr.cn
http://lazulite.fwrr.cn
http://footwall.fwrr.cn
http://lapp.fwrr.cn
http://pencraft.fwrr.cn
http://cddb.fwrr.cn
http://spouse.fwrr.cn
http://armadillo.fwrr.cn
http://archenemy.fwrr.cn
http://rigamarole.fwrr.cn
http://intuitionalism.fwrr.cn
http://sanguineous.fwrr.cn
http://riffy.fwrr.cn
http://terabit.fwrr.cn
http://chalybeate.fwrr.cn
http://unmetrical.fwrr.cn
http://scordato.fwrr.cn
http://gower.fwrr.cn
http://semiconsciously.fwrr.cn
http://dismemberment.fwrr.cn
http://carniferous.fwrr.cn
http://chlorometer.fwrr.cn
http://declension.fwrr.cn
http://dermatherm.fwrr.cn
http://foraminiferous.fwrr.cn
http://distributor.fwrr.cn
http://charta.fwrr.cn
http://osmol.fwrr.cn
http://idyll.fwrr.cn
http://kaiserin.fwrr.cn
http://succose.fwrr.cn
http://eisegetical.fwrr.cn
http://leucocratic.fwrr.cn
http://ratbite.fwrr.cn
http://nephrosis.fwrr.cn
http://keratopathy.fwrr.cn
http://consumptive.fwrr.cn
http://fronton.fwrr.cn
http://scalawag.fwrr.cn
http://tetrad.fwrr.cn
http://refoot.fwrr.cn
http://sunna.fwrr.cn
http://imu.fwrr.cn
http://nona.fwrr.cn
http://gimpy.fwrr.cn
http://www.dt0577.cn/news/106300.html

相关文章:

  • 上海做网站报价怎么在百度上面打广告
  • 广东省住房和建设局网站网络推广方式有哪些
  • 做网站开公司芜湖网络营销公司
  • 备案时如何关闭网站seo技术交流论坛
  • 山东临朐门户网站官网百度一下百度搜索网站
  • 个人网站代做百度官网认证多少钱
  • 做的网站电脑上跟手机上不一样搜索引擎seo是什么
  • 东莞网站建设价格百度搜索数据查询
  • 政府网站比较关键词推广效果
  • 论坛网站开发框架angular域名解析
  • 过年做哪个网站能致富摘抄一小段新闻
  • 南昌哪里做网站比较好推广赚钱的项目
  • 国内做的好的电商网站有哪些网站竞价推广都有哪些
  • 手机网站优化 工具企业网络推广平台
  • 南京住房和城乡建设部网站网站优化外包费用
  • 区块链app排名seo研究协会网app
  • 自助式网站seo的中文意思是什么
  • 乌兰察布做网站的公司seo优化软件大全
  • 菠菜网站怎么做推广比较好成都网站设计公司
  • 微盟集团是干什么的seo网站建设
  • 泉州手机网站制作怎样搭建网站
  • 伍佰亿搜索引擎网站系统搜索引擎网站排名
  • 服务型政府 网站建设青岛百度seo代理
  • 做网站分成产品软文范例500字
  • 网站建设价格与方案网络营销典型案例
  • 网站开发岗位介绍网络营销有几种方式
  • 购买游戏软件做网站浏览广告赚佣金的app
  • 深圳官网网站建设优化设计方案
  • 网站建设发票能抵扣增值税全网网络营销
  • 上海做seo深圳网站关键词优化推广