简体   繁体   English

将给定的节点链(链表)一分为二,返回另一半

[英]Splits the given node chain (linked list) in half, returning the second half

I would like to Splits the given node chain(linked list) in half, returning the second half.我想将给定的节点链(链表)一分为二,返回另一半。 If the given chain has an odd length, the extra node is part of the second half of the chain.如果给定链的长度为奇数,则额外节点是链后半部分的一部分。

I wont do your homeworks but here are some things that can help you:我不会做你的功课,但这里有一些可以帮助你的事情:

  • What is the length of the chain (to know where to stop)链条的长度是多少(知道在哪里停止)
  • How can I find the length of the chain我怎样才能找到链条的长度
  • How can I use that information to stop on the correct node我如何使用该信息在正确的节点上停止
  • Once I am there, what do I return, what am I doing ?一旦我到了那里,我要返回什么,我在做什么?
  • Is it correct ?这是正确的吗 ? I should test it to be sure.我应该测试它以确保。
  • Success !!!成功 !!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM