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

西宁做网站的优化大师win10下载

西宁做网站的,优化大师win10下载,win7 iis配置网站 视频教程,群辉域名登录wordpress嗯哼~ 题目 描述 假设链表中每一个节点的值都在 0 - 9 之间,那么链表整体就可以代表一个整数。 给定两个这种链表,请生成代表两个整数相加值的结果链表。 数据范围:0 ≤ n,m ≤ 1000000,链表任意值 0 ≤ val ≤ 9 要求&#x…

 嗯哼~



题目

描述

假设链表中每一个节点的值都在 0 - 9 之间,那么链表整体就可以代表一个整数。

给定两个这种链表,请生成代表两个整数相加值的结果链表。

数据范围:0 ≤ n,m ≤ 1000000,链表任意值 0 ≤ val ≤ 9
要求:空间复杂度 O(n),时间复杂度 O(n)

示例 



思路 

 

单链表的翻转详细讲解:反转一个单链表(<---点击可看详解)



 

题解代码

struct ListNode* ReverseList(struct ListNode* pHead)
{// write code herestruct ListNode* cur = pHead;struct ListNode* pre = NULL;while (cur != NULL){struct ListNode* temp = cur->next;cur->next = pre;pre = cur;cur = temp;}return pre;
}struct ListNode* addInList(struct ListNode* head1, struct ListNode* head2)
{// write code herehead1 = ReverseList(head1);head2 = ReverseList(head2);int temp = 0;int add = 0;struct ListNode* newhead = NULL;while (head1 && head2){temp = (head1->val + head2->val + add);if (temp >= 10){add = 1;temp %= 10;}else{add = 0;}struct ListNode* cur = (struct ListNode*)malloc(sizeof(struct ListNode));cur->val = temp;cur->next = newhead;newhead = cur;head1 = head1->next;head2 = head2->next;}struct ListNode* empty = head1;struct ListNode* nonempty = head2;if (head1 != NULL){empty = head2;nonempty = head1;}while (nonempty){temp = (nonempty->val + add);if (temp >= 10){add = 1;temp %= 10;}else{add = 0;}struct ListNode* cur = (struct ListNode*)malloc(sizeof(struct ListNode));cur->val = temp;cur->next = newhead;newhead = cur;nonempty = nonempty->next;}if (add == 1){struct ListNode* cur = (struct ListNode*)malloc(sizeof(struct ListNode));cur->val = 1;cur->next = newhead;newhead = cur;}return newhead;}


 个人主页:Lei宝啊

愿所有美好如期而遇

http://www.hkea.cn/news/767146/

相关文章:

  • 哪里有网站设计公司长沙网络公司最新消息
  • 试描述一下网站建设的基本流程百度怎么发布短视频
  • 我现在有域名怎么做网站搜索关键词热度
  • 海外如何 淘宝网站建设快速seo整站优化排行
  • 代还信用卡网站建设赣州seo顾问
  • 响应式网站建设推广开网店
  • 成都专业网站推广公司优化大师优化项目有
  • 怎么用wordpress搭建网站百度关键词排名点
  • 外挂网站模板域名搜索引擎入口
  • 手机网站开发 pdfseo搜索引擎优化工作内容
  • 上海中小网站建设洛阳seo博客
  • 南宁网站建设公司哪家专业搜索引擎优化包括
  • 新疆住房与建设厅网站新产品推广方式有哪些
  • 做网站站怎么赚钱网络营销模式有哪些?
  • 南通城市建设集团有限公司网站南京谷歌推广
  • 南通网站定制方案怎么查找关键词排名
  • 权大师的网站是哪个公司做的百度做个人简介多少钱
  • 烟台网站建设设计软文广告经典案例100字
  • 做微信用什么网站广州百度seo代理
  • 网站建设目标 优帮云跨境电商营销推广
  • 郑州华恩科技做网站怎么样竞价排名适合百度吗
  • flask做大型网站开发深圳seo博客
  • 合肥网站建设平台小程序怎么引流推广
  • 做网站被拘留免费找客源软件
  • 门户型网站建设百度seo快速提升排名
  • 印度做杂质的网站如何进行网络推广
  • 建设厅八大员兴安盟新百度县seo快速排名
  • 南京网站建设索q.479185700小说排行榜百度
  • 幼儿做爰网站seo工程师是什么职业
  • 申请空间 建立网站吗西安百度推广运营