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

【单链表OJ题:反转链表】

题目来源

/*** Definition for singly-linked list.* struct ListNode {*     int val;*     struct ListNode *next;* };*/
struct ListNode* reverseList(struct ListNode* head){struct ListNode* current = head;struct ListNode* newnode = NULL;while(current!=NULL){struct ListNode* next = current->next;current->next = newnode;newnode = current;current = next;}return newnode;
}
/*** Definition for singly-linked list.* struct ListNode {*     int val;*     struct ListNode *next;* };*/struct ListNode* reverseList(struct ListNode* head){//反转链表使用头插法//需要使用三个指针struct ListNode* begin = head;struct ListNode* end = NULL;if(begin!=NULL)end = begin->next;struct ListNode* newhead = NULL;while(begin!=NULL){begin->next = newhead;newhead = begin;begin = end;if(end!=NULL)end = end->next;}return newhead;
}
http://www.lryc.cn/news/102931.html

相关文章:

  • Unity UGUI的LayoutRebuilder的介绍及使用
  • 深刻理解python特性-列表推导式和生成器表达式
  • Sentinel dashboard的使用;Nacos保存Sentinel限流规则
  • vue学习之插值表达式{{}}与显示数据(v-text和v-html)
  • 2,认识N(logN)的排序【p3】
  • 华为机考--服务失效判断--带答案
  • C++对C的加强(全)
  • ES6及以上新特性
  • 伦敦金在非农双向挂单
  • 【C语言】—— __attribute__((fallthrough))
  • 【深度学习】生成对抗网络Generative Adversarial Nets
  • 【深度学习】从现代C++中的开始:卷积
  • 金融数学方法:蒙特卡洛模拟
  • vue 文件扩展名中 esm 、common 、global 以及 mini 、 dev 、prod 、runtime 的含义
  • 微服务契约测试框架Pact-Python实战
  • Linux 给用户 赋某个文件夹操作的权限(实现三权分立)
  • 【C++入门到精通】C++入门 —— 类和对象(初始化列表、Static成员、友元、内部类、匿名对象)
  • “深入理解Spring Boot:从入门到高级应用“
  • Apache Spark 的基本概念和在大数据分析中的应用
  • Debian LNMP架构的简单配置使用
  • CAN转EtherNet/IP网关can协议破解服务
  • 最适合新手的Java项目/SpringBoot+SSM项目《苍穹外卖》/项目实战、笔记(超详细、新手)[持续更新……]
  • CloudDriver一款将各种网盘云盘挂在到电脑本地变成本地磁盘的工具 教程
  • 行为型模式之中介者模式
  • BPMNJS插件使用及汉化(Activiti绘制流程图插件)
  • STM32使用HAL库中外设初始化MSP回调机制及中断回调机制详解
  • Hutool工具类FileUtil----文件(夹)创建、删除、添加数据
  • Flink - souce算子
  • 使用vue creat搭建项目
  • 面试题 -- 基础知识