当前位置:网站首页>876. Intermediate node of linked list
876. Intermediate node of linked list
2022-07-04 19:21:00 【charlsdm】
- The middle node of a list
Given a header node as head The non empty single chain table of , Returns the middle node of the linked list .
If there are two intermediate nodes , Then return to the second intermediate node .
Example 1:
Input :[1,2,3,4,5]
Output : Nodes in this list 3 ( Serialization form :[3,4,5])
The returned node value is 3 . ( The evaluation system expresses the serialization of this node as follows [3,4,5]).
Be careful , We returned one ListNode Object of type ans, such :
ans.val = 3, ans.next.val = 4, ans.next.next.val = 5, as well as ans.next.next.next = NULL.
Example 2:
Input :[1,2,3,4,5,6]
Output : Nodes in this list 4 ( Serialization form :[4,5,6])
Because the list has two intermediate nodes , Values, respectively 3 and 4, Let's go back to the second node .
Tips :
The number of nodes in a given list is between 1 and 100 Between .
Attached below is my AC Code
public partial class Solution
{
public ListNode MiddleNode(ListNode head)
{
ListNode[] listNodes = new ListNode[100];
int index = 0;
while(head!=null)
{
listNodes[index] = head;
head = head.next;
index = index + 1;
}
return listNodes[(index)/2];
}
}
边栏推荐
- 激进技术派 vs 项目保守派的微服务架构之争
- 6.26CF模拟赛E:价格最大化题解
- 整理混乱的头文件,我用include what you use
- NBA赛事直播超清画质背后:阿里云视频云「窄带高清2.0」技术深度解读
- 建立自己的网站(15)
- 2019年蜀山区第十五届青少年信息学竞赛
- Wireshark packet capturing TLS protocol bar displays version inconsistency
- Li Kou brush question diary /day1/2022.6.23
- A method of using tree LSTM reinforcement learning for connection sequence selection
- PB的扩展DLL开发(超级篇)(七)
猜你喜欢
Nature Microbiology | 可感染阿斯加德古菌的六种深海沉积物中的病毒基因组
Microservice architecture debate between radical technologists vs Project conservatives
正则替换【JS,正则表达式】
Principle and application of ThreadLocal
redis分布式锁的8大坑总结梳理
Wireshark抓包TLS协议栏显示版本不一致问题
[release] a tool for testing WebService and database connection - dbtest v1.0
奥迪AUDI EDI INVOIC发票报文详解
Scala basic tutorial -- 13 -- advanced function
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
随机推荐
Angry bird design based on unity
Caché WebSocket
建立自己的网站(15)
Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片
Scala basic tutorial -- 12 -- Reading and writing data
使用SSH
正则替换【JS,正则表达式】
DeFi生态NFT流动性挖矿系统开发搭建
【2022年江西省研究生数学建模】冰壶运动 思路分析及代码实现
Don't just learn Oracle and MySQL!
Scala basic tutorial -- 18 -- set (2)
TorchDrug教程
每日一题(2022-07-02)——最低加油次数
Go microservice (II) - detailed introduction to protobuf
[mathematical basis of machine learning] (I) linear algebra (Part 1 +)
Using FTP
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
2022养生展,健康展,北京大健康展,健康产业展11月举办
Torchdrug tutorial
国元期货是正规平台吗?在国元期货开户安全吗?