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

做购物商城网站wordpress插件免费吗

做购物商城网站,wordpress插件免费吗,网站的企业风采怎么做,淄博手机网站建设报价1.题目 https://leetcode.cn/problems/merge-two-sorted-lists/ 将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 示例 1#xff1a; 输入#xff1a;l1 [1,2,4], l2 [1,3,4] 输出#xff1a;[1,1,2,3,4,4]示例 2…1.题目 https://leetcode.cn/problems/merge-two-sorted-lists/ 将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。  示例 1 输入l1 [1,2,4], l2 [1,3,4] 输出[1,1,2,3,4,4]示例 2 输入l1 [], l2 [] 输出[]示例 3 输入l1 [], l2 [0] 输出[0]提示 两个链表的节点数目范围是 [0, 50]-100 Node.val 100l1 和 l2 均按 非递减顺序 排列代码模版 /*** Definition for singly-linked list.* struct ListNode {* int val;* struct ListNode *next;* };*/ struct ListNode* mergeTwoLists(struct ListNode* list1, struct ListNode* list2) { } 2.自解 一个容易想到的解法:取小的尾插(开一个新的链表) 对于链表list1和list2,可以另外开一个新的链表,再将list1和list2的val复制进新链表的节点,最后返回新链表的头结点的地址即可 不加思索写出以下代码: /*** Definition for singly-linked list.* struct ListNode {* int val;* struct ListNode *next;* };*/ struct ListNode* mergeTwoLists(struct ListNode* list1, struct ListNode* list2) {struct ListNode* cur1list1;struct ListNode* cur2list2;if (list1NULL)return list2;if (list2NULL)return list1;struct newListNode{int new_val;struct ListNode* new_next;};struct newListNode* new_nextNULL;struct newListNode* newheadNULL;struct newListNode* m_m_new(struct newListNode*)malloc(sizeof(struct newListNode));newheadm_m_new;newhead-new_nextNULL;struct newListNode* new_curnewhead;while(cur1!NULL cur2!NULL){if (cur1NULL){new_cur-new_valcur2-val;cur2cur2-next;//分配新结点的空间struct newListNode* m_new(struct newListNode*)malloc(sizeof(struct newListNode));new_cur-new_nextm_new;new_curm_new;continue;}if (cur2NULL){new_cur-new_valcur1-val;cur1cur1-next;struct newListNode* m_new(struct newListNode*)malloc(sizeof(struct newListNode));new_cur-new_nextm_new;new_curm_new;continue;}if (cur1-valcur2-val){new_cur-new_valcur1-val;cur1cur1-next;struct newListNode* m_new(struct newListNode*)malloc(sizeof(struct newListNode));new_cur-new_nextm_new;new_curm_new;}else{new_cur-new_valcur2-val;cur2cur2-next;//分配新结点的空间struct newListNode* m_new(struct newListNode*)malloc(sizeof(struct newListNode));new_cur-new_nextm_new;new_curm_new;}}new_cur-new_nextNULL;new_curNULL;return newhead; } 运行时出现问题 发现while循环的条件写错了!! 应该改成 while(!(cur1NULL cur2NULL)) 完整代码 struct ListNode* mergeTwoLists(struct ListNode* list1, struct ListNode* list2) {struct ListNode* cur1list1;struct ListNode* cur2list2;if (list1NULL)return list2;if (list2NULL)return list1;struct newListNode{int new_val;struct ListNode* new_next;};struct newListNode* new_nextNULL;struct newListNode* newheadNULL;struct newListNode* m_m_new(struct newListNode*)malloc(sizeof(struct newListNode));newheadm_m_new;newhead-new_nextNULL;struct newListNode* new_curnewhead;struct newListNode* before_new_curNULL;while(!(cur1NULL cur2NULL)){if (cur1NULL){new_cur-new_valcur2-val;cur2cur2-next;struct newListNode* m_new(struct newListNode*)malloc(sizeof(struct newListNode));new_cur-new_nextm_new;before_new_curnew_cur;new_curm_new;new_cur-new_nextNULL;continue;}if (cur2NULL){new_cur-new_valcur1-val;cur1cur1-next;struct newListNode* m_new(struct newListNode*)malloc(sizeof(struct newListNode));new_cur-new_nextm_new;before_new_curnew_cur;new_curm_new;continue;}if (cur1-valcur2-val){new_cur-new_valcur1-val;cur1cur1-next;struct newListNode* m_new(struct newListNode*)malloc(sizeof(struct newListNode));new_cur-new_nextm_new;new_curm_new;}else{new_cur-new_valcur2-val;cur2cur2-next; struct newListNode* m_new(struct newListNode*)malloc(sizeof(struct newListNode));new_cur-new_nextm_new;new_curm_new;}}before_new_cur-new_nextNULL;return newhead; } before_new_cur是当cur1NULL或cur2NULL,备份new_cur的前一个节点的地址 提交结果 3.其他解法 方法1:取小的尾插(不开新链表) struct ListNode* mergeTwoLists(struct ListNode* list1, struct ListNode* list2) {struct ListNode* cur1list1;struct ListNode* cur2list2;struct ListNode* headNULL;struct ListNode* tailNULL;if (list1NULL)return list2;if (list2NULL)return list1;while (cur1 cur2){if (cur1-valcur2-val){if (headNULL){headtailcur1;}else{tail-nextcur1;tailtail-next;}cur1cur1-next;}else{if (headNULL){headtailcur2;}else{tail-nextcur2;tailtail-next;}cur2cur2-next; }}if(cur1)tail-nextcur1;if(cur2)tail-nextcur2;return head; } 分析 尾插要有尾指针tail(这样不用频繁找尾),同时要有指向头节点的指针head用于返回 cur1-valcur2-val和cur1-valcur2-val操作方式是类似的
http://www.hkea.cn/news/14393144/

相关文章:

  • 做婚礼网站的公司iis上部署wordpress
  • 新手学做网站要学什么知识图文教程网站建设客户确认单
  • 网站评估怎么做建设摩托125图片大全
  • 住宅与建设部网站创新的网站建站
  • 怎么做英文的网站wordpress后台模板
  • 苏州网站制作哪家好免费网页模板素材
  • 怎么做足球网站共同建设网站协议
  • 卫生院网站建设做网站用微软雅黑
  • 网站建设的各种组成wordpress大图简约主题
  • 做个人网站怎么做微山县建设局官方网站
  • 手机销售网站怎么做的wordpress 批量换
  • ps做网站页面先后顺序手机网站搜索优化
  • 网站建设是属现代服务吗招商网站建设的必要性
  • 做网站建设要什么证做网站公司上什么平台
  • 网站的按钮怎么做的html编辑器手机
  • 网站备案资料网站设计样例
  • 企业门户网站建设机构中信建设有限责任公司中标项目
  • php网站开发技术文档网站建设翻译
  • 作品集公司网站商业网站初期建设资金预算
  • 烟台网站关键词推广找房网58同城买房
  • 网站建设的主要职责网络广告策划
  • 个人网站如何做移动端免费采购信息平台
  • dz网站设置了关键词但是不显示网络文化经营许可证流程
  • 凡科做网站视频wordpress sae 4.4
  • 南通市住房城乡建设局网站手机网站功能开发方案
  • 山西省建设厅网站打不开单职业传奇手机手游版
  • 唐山做网站建设的公司网站备案还是域名备案
  • 海城市建设局网站苏州网站建设服务公司
  • 如何做设计网站页面设计电子商务网站建设与管理试题
  • 网站建设与维护技术浅谈论文新乡+网站建设