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

腾讯云可以做网站吗3做租赁哪个网站好

腾讯云可以做网站吗3,做租赁哪个网站好,旅行志 wordpress,深圳有哪些物流公司题目:LCR 026 解法一:线性表 将链表中所有元素加入数组中,创建两个指针,分别指向数组的头部和尾部,然后向中间遍历 public void reorderList(ListNode head) {if (head null || head.next null || head.next.next …

题目:LCR 026


解法一:线性表

将链表中所有元素加入数组中,创建两个指针,分别指向数组的头部和尾部,然后向中间遍历

    public void reorderList(ListNode head) {if (head == null || head.next == null || head.next.next == null) return;List<ListNode> list = new ArrayList<>();ListNode cur = head;while (cur != null) {list.add(cur);cur = cur.next;}ListNode reorderNode = new ListNode(0, head);for (int i = 0; i < list.size(); i++) {int index1 = i, index2 = list.size() - 1 - i;ListNode start = list.get(index1);ListNode end = list.get(index2);if (index1 == index2) {reorderNode.next = start;start.next = null;break;} else if (index1 == index2 - 1) {reorderNode.next = start;start.next = end;end.next = null;break;} else {reorderNode.next = start;start.next = end;reorderNode = end;}}}

解法二:寻找链表中点 + 链表逆序 + 合并链表

    public void reorderList(ListNode head) {if (head == null || head.next == null || head.next.next == null) return;ListNode middleNode = middleNode(head);ListNode reversedList = reverseList(middleNode);mergeList(head, reversedList);}public ListNode mergeList(ListNode head1, ListNode head2) {if (head1 == null || head2 == null) return head1;ListNode dummy = new ListNode(0), prev = dummy, node1 = head1, node2 = head2;while (node2 != null) {if (node1 == node2) {prev.next = node2;break;}ListNode nextNode1 = node1.next;ListNode nextNode2 = node2.next;prev.next = node1;node1.next = node2;prev = node2;node1 = nextNode1;node2 = nextNode2;}return dummy.next;}public ListNode middleNode(ListNode head) {if (head == null || head.next == null) return head;ListNode slow = head, fast = head;while (fast != null && fast.next != null) {slow = slow.next;fast = fast.next.next;}return slow;}public ListNode reverseList(ListNode head) {ListNode prev = null, cur = head, next;while (cur != null) {next = cur.next;cur.next = prev;prev = cur;cur = next;}return prev;}

http://www.yayakq.cn/news/160607/

相关文章:

  • 上海产品网站建设做网站前台需要学什么 后台
  • 猪八戒网做网站怎么样微信商城开发用华网天下卓越
  • 可以给别人做ps设计的网站中小企业网站建设价格
  • 网站图片怎么做的高级平面设计赚钱平台
  • 建设网站搞网络营销的总结怎样建设网站优化
  • 网站反链一般怎么做在线生成个人网站推荐
  • 网站版式分类公众号 商城 网站开发
  • 网站扩展名谷歌推广新手教程
  • 郑州网站设计 公司手机营销网站模板
  • 打开网站弹出广告代码南昌自动seo
  • 集团网站 源码网页设计需要学什么编程
  • 商城类网站建设的服务器选择抖音小程序开通
  • 广元建设机械网站重庆美食制作
  • 拉链网站源码做网上商城网站
  • 长春网站制作哪里好打开网站后直接做跳转页面吗
  • 企业网站翻译大型门户网站
  • 建设医疗网站合肥建站企业
  • 百度不收录哪些网站科技感网站设计
  • 珠海网站网站建设新网站做百度推广
  • 佛山 做网站公司有哪些91手表网
  • 旅游网站设计代码html自己做的网站设定背景图像
  • cms进行网站开发绩效管理网站开发
  • 网站总体结构廊坊网站定制开发
  • 企业门户网站模板wordpress文章密码爆破
  • 微信创建网站应用程序wordpress的文章分类
  • 国外免费空间哪个好优化方案语文
  • 程序员做网站美工能过关吗网站建设与维护的选择题
  • 青州建网站wordpress主题讲解
  • 天津 企业网站建设网站换了域名做跳转
  • 广告公司网站设计策划专做茶叶的网站