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

苹果销售网站怎么做的推广运营是什么工作

苹果销售网站怎么做的,推广运营是什么工作,世界疫情最新数据排行榜,营销型网站建设 课程方法一:暴力求解 1️⃣遍历原链表,复制节点尾插 2️⃣更新random,原链表中的random对应第几个节点则复制链表中的random就对应第几个 📖Note 不能通过节点中的val判断random的指向,因为链表中可能存在两个val相等的节点…

方法一:暴力求解

1️⃣遍历原链表,复制节点尾插

2️⃣更新random,原链表中的random对应第几个节点则复制链表中的random就对应第几个

📖Note

不能通过节点中的val判断random的指向,因为链表中可能存在两个val相等的节点

//创建节点
struct Node* BuyNode(int x)
{struct Node* newnode = (struct Node*)malloc(sizeof(struct Node));newnode->val = x;newnode->next = NULL;return newnode;
}//找到random对应的节点是第几个
int FindRandom(struct Node* head, struct Node* random)
{int count = 1;while (head){if (head == random){return count;}else {count++;head = head->next;}}return count;
}struct Node* copyRandomList(struct Node* head) {struct Node* guard = (struct Node*)malloc(sizeof(struct Node));guard->next = NULL;struct Node* tail = guard;struct Node* cur = head;//复制原链表while (cur){struct Node* newnode = BuyNode(cur->val);tail->next = newnode;tail = tail->next;cur = cur->next;}//tail和cur都指向新链表的头tail = guard->next;struct Node* tmp = head;//更新randomwhile (tail){//在原链表这种判断random指向的节点是第几个int count = FindRandom(head, tmp->random);tmp = tmp->next;//更新复制链表中的randomcur = guard->next;while (count--){tail->random = cur;if (cur){cur = cur->next;}}tail = tail->next;}struct Node* newhead = guard->next;free(guard);return newhead;}

方法二:

1️⃣拷贝原节点,并链接在原节点之后

2️⃣更新拷贝节点中的random

拷贝节点中的random指向的是原节点中random指向节点的下一个节点

3️⃣将拷贝的节点解下来构成新的复制链表

struct Node* copyRandomList(struct Node* head) {struct Node* cur = head;struct Node* copy = NULL;//拷贝原节点,并链接在原节点之后while (cur){copy = (struct Node*)malloc(sizeof(struct Node));copy->val = cur->val;copy->next = cur->next;cur->next = copy;cur = cur->next->next;}//更新拷贝节点的randomcur = head;while (cur){copy = cur->next;if (cur->random){copy->random = cur->random->next;}else{copy->random = NULL;}cur = cur->next->next;}//将所有拷贝节点解下来构成新链表并恢复原链表结构cur = head;struct Node* copyhead, *copytail;copyhead = copytail = NULL;while (cur){copy = cur->next;//取节点尾插if (copytail == NULL){copyhead = copytail = copy;}else{copytail->next = copy;copytail = copytail->next;}//恢复原链表cur->next = copy->next;cur = copy->next;}return copyhead;
}

http://www.jinmujx.cn/news/110699.html

相关文章:

  • 最简单的网站怎么做重庆百度
  • 网站安全管理机制建设网址查询ip地址
  • 使用tag的网站杭州最专业的seo公司
  • 网站生成静态页面工具seo排名优化哪家好
  • 网站建设 八羊什么平台打广告比较好免费的
  • 建一个定制网站要多少钱中国最厉害的营销策划公司
  • java网站开发书籍关键词搜索引擎排名查询
  • 网站建设中备案数字营销策略有哪些
  • 网络策划主要做什么下载优化大师并安装
  • 做网站推广需要做什么小红书关键词排名优化
  • 网络架构有哪些seo外包优化
  • 做网站后台的时候要注意什么seo企业顾问
  • 网站关键词指数查询云南网络推广
  • 路由器做内部网站服务器sem广告投放是做什么的
  • 湖南网站推广公司合肥网络推广
  • 淮南网站建设科技有限公司百度入口提交
  • 小语种网站怎么做优化大师官方免费下载
  • 专题页网站百度搜索页
  • 网站建设的优势是什么chrome手机版
  • 网站做软件网络广告推广平台
  • steamcn网站是谁做的营销课程培训哪个机构好
  • 网站开发工具排行营销型网站建设多少钱
  • 酒泉百度做网站多少钱seo少女
  • 网站需要哪些手续如何优化关键词的方法
  • 个人营业执照办理seo是什么缩写
  • WordPress图床源码重庆seo排名公司
  • 网站制作方案介绍及要求苏州网站制作推广
  • 网站建设有哪些工作需需要筹备本周新闻热点10条
  • 网站用户后台是怎么做的广东seo推广外包
  • 长春企业建站程序佛山网站快速排名提升