当前位置:网站首页>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];
}
}
边栏推荐
- Using FTP
- Scala基础教程--12--读写数据
- Angry bird design based on unity
- C # implementation defines a set of SQL statements that can be executed across databases in the middle of SQL (detailed explanation of the case)
- 2022养生展,健康展,北京大健康展,健康产业展11月举办
- LeetCode FizzBuzz C#解答
- Don't just learn Oracle and MySQL!
- Principle and application of ThreadLocal
- [mathematical basis of machine learning] (I) linear algebra (Part 1 +)
- ESP32-C3入门教程 问题篇⑫——undefined reference to rom_temp_to_power, in function phy_get_romfunc_addr
猜你喜欢
基于lex和yacc的词法分析器+语法分析器
Scala basic tutorial -- 13 -- advanced function
更安全、更智能、更精致,长安Lumin完虐宏光MINI EV?
【2022年江西省研究生数学建模】水汽过饱和的核化除霾 思路分析及代码实现
正则替换【JS,正则表达式】
ByteDance dev better technology salon was successfully held, and we joined hands with Huatai to share our experience in improving the efficiency of web research and development
Scala basic tutorial -- 18 -- set (2)
Scala基础教程--16--泛型
2022CoCa: Contrastive Captioners are Image-Text Fountion Models
[go ~ 0 to 1] read, write and create files on the sixth day
随机推荐
LeetCode 赎金信 C#解答
2022年字节跳动日常实习面经(抖音)
repeat_P1002 [NOIP2002 普及组] 过河卒_dp
Scala基础教程--13--函数进阶
How to modify icons in VBS or VBE
一种将Tree-LSTM的强化学习用于连接顺序选择的方法
6.26CF模拟赛B:数组缩减题解
Go微服务(二)——Protobuf详细入门
基于unity的愤怒的小鸟设计
2022健康展,北京健博会,中国健康展,大健康展11月13日
Process of manually encrypt the mass-producing firmware and programming ESP devices
Is the securities account opened by qiniu safe?
Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片
Wireshark packet capturing TLS protocol bar displays version inconsistency
[发布] 一个测试 WebService 和数据库连接的工具 - DBTest v1.0
LeetCode FizzBuzz C#解答
DeFi生态NFT流动性挖矿系统开发搭建
Nature microbiology | viral genomes in six deep-sea sediments that can infect Archaea asgardii
建立自己的网站(15)
字节跳动Dev Better技术沙龙成功举办,携手华泰分享Web研发效能提升经验