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

小程序app开发多少钱网站如何优化排名软件

小程序app开发多少钱,网站如何优化排名软件,怎样做网站变手机软件,无锡网络公司平台题目一: 题目链接: 思路一: 找相对位置暴力求解的方法: 1.复制一个新的链表出来遍历老的节点给新的节点赋值,random这个时候不去值。 2.两个链表同时遍历,遍历老链表的时候去寻找相对位置,在遍…

题目一:

请添加图片描述
题目链接:

思路一:

找相对位置暴力求解的方法:
1.复制一个新的链表出来遍历老的节点给新的节点赋值,random这个时候不去值。
2.两个链表同时遍历,遍历老链表的时候去寻找相对位置,在遍历新的链表找到随机值赋值。

struct Node* copyRandomList(struct Node* head) {struct Node* cur=head;struct Node* newhead=NULL,*tile=NULL;//复制原来的链表数据while(cur){//开辟新的节点struct Node* newnode=(struct Node*)malloc(sizeof(struct Node));newnode->val=cur->val;newnode->next=NULL;newnode->random=NULL;if(newhead==NULL){tile=newhead=newnode;}else{tile->next=newnode;tile=tile->next;}cur=cur->next;}//进行两个的循环遍历,找相对位置cur=head;struct Node* cur2=newhead;int pos=0;while(cur){//更新一下pospos=0;//cur的随机值是哪一个struct Node* find=cur->random;if(find==NULL){cur2->random=NULL;cur=cur->next;cur2=cur2->next;continue;}else{struct Node* curold=head;while(curold){if(find==curold){break;}pos++;curold=curold->next;}}//寻找随机节点struct Node* curnew=newhead;while(pos){curnew=curnew->next;pos--;}cur2->random=curnew;//循环条件cur=cur->next;cur2=cur2->next;}return newhead;
}

思路二:

请添加图片描述

struct Node* copyRandomList(struct Node* head) {struct Node* cur = head, * tile = NULL;//新的链表赋值插入,cur为空才结束插入while (cur){//保存下一个老的tile = cur->next;struct Node* newnode = (struct Node*)malloc(sizeof(struct Node));newnode->val = cur->val;cur->next = newnode;newnode->next = tile;//循环条件cur = tile;}//给copy链表赋值randomstruct Node* copy = NULL;cur = head;tile = NULL;while (cur){//连接了新的节点copy = cur->next;tile = copy->next;//给random赋值,随机值,正常值的两个情况if (cur->random == NULL){copy->random = NULL;}else{copy->random = cur->random->next;}//循环的移动cur = tile;}copy = NULL;cur = head;tile = NULL;//分离链表struct Node* newhead = NULL;struct Node* move = NULL;while (cur){copy = cur->next;tile = copy->next;if (newhead == NULL){newhead = copy;move = newhead;}else{move->next = copy;move = move->next;}//恢复原来的节点cur->next = tile;//循环遍历cur = tile;}return newhead;}
http://www.dinnco.com/news/61337.html

相关文章:

  • 怎么上网做网站跨境电商平台有哪些
  • fw可以做网站网站软件下载app
  • 做网站官网好处谷歌seo网站排名优化
  • 上海建立网站公司全球新闻最新消息
  • 专门做实习计算机项目的网站平台百度竞价排名算法
  • 成人本科有用吗深圳seo技术
  • 大型网站开发语言排名网站技术制作
  • 为女友做网站识万物扫一扫
  • 做网站有效果吗百度网盘客服在线咨询
  • 免备案做网站 可以盈利吗网站的设计流程
  • 张家港网站哪家做的好网络营销心得体会800字
  • 实惠网站建设国内可访问的海外网站和应用
  • 赌球网站如何做代理网络推广的主要内容
  • 宝鸡市城乡建设规划局官方网站线上推广有哪些渠道
  • 做网站所用的工具百度关键词搜索排名多少钱
  • 网站设置首页连接分类页的视频教程app推广公司
  • 网站建设与动态网页网店培训班
  • 专门做汽车gps贷款网站百度推广有哪些售后服务
  • 网站开发中安全性免费网站电视剧全免费
  • 自己做网站都要什么手续网店代运营公司哪家好
  • 广州建设集团有限公司广州seo全网营销
  • 做纸贸易的好网站网络推广运营主要做什么
  • 企业企业网站建设兰州怎么提高网站的排名
  • 做盗链网站seo培训师
  • 英文淘宝网站建设网站推广优化怎么做最好
  • 创业做招聘网站靠谱吗seo网站优化方案案例
  • 网页设计工资一般多少钱一小时seo站群优化技术
  • 琼海做网站口碑百度快速收录入口
  • 国家建设工程质量检查标准网站51链
  • wordpress 数据库解析什么是白帽seo