当前位置:网站首页>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];
}
}
边栏推荐
- 神经网络物联网应用技术就业前景【欢迎补充】
- 利用策略模式优化if代码【策略模式】
- Unity编辑器扩展C#遍历文件夹以及子目录下的所有图片
- Scala基础教程--12--读写数据
- Perfect JS event delegation
- One question per day (2022-07-02) - Minimum refueling times
- C语言打印练习
- 6.26cf simulation match B: solution to array reduction problem
- Basic tutorial of scala -- 16 -- generics
- Scala basic tutorial -- 17 -- Collection
猜你喜欢
Scala basic tutorial -- 19 -- actor
MXNet对GoogLeNet的实现(并行连结网络)
Process of manually encrypt the mass-producing firmware and programming ESP devices
性能优化之关键渲染路径
vbs或vbe如何修改图标
Safer, smarter and more refined, Chang'an Lumin Wanmei Hongguang Mini EV?
Microservice architecture debate between radical technologists vs Project conservatives
建立自己的网站(15)
Scala basic tutorial -- 17 -- Collection
Scala基础教程--19--Actor
随机推荐
2022-07-04:以下go语言代码输出什么?A:true;B:false;C:编译错误。 package main import 'fmt' func
sqlserver的CDC第一次查询的能读取到数据,但后面增删改读取不到,是什么原因
C language printing exercise
vbs或vbe如何修改图标
C#实现定义一套中间SQL可以跨库执行的SQL语句(案例详解)
国元期货是正规平台吗?在国元期货开户安全吗?
神经网络物联网是什么意思通俗的解释
TorchDrug教程
启牛开的证券账户安全吗?
2021 合肥市信息学竞赛小学组
Guys, for help, I use MySQL CDC 2.2.1 (Flink 1.14.5) to write Kafka and set
Li Kou brush question diary /day1/2022.6.23
物联网应用技术的就业前景和现状
发送和接收IBM WebSphere MQ消息
876. 链表的中间结点
Scala基础教程--17--集合
大佬们,求助一下,我用mysql cdc 2.2.1(flink 1.14.5)写入kafka,设置
Esp32-c3 introductory tutorial questions ⑫ - undefined reference to ROM_ temp_ to_ power, in function phy_ get_ romfunc_ addr
C语言打印练习
基于lex和yacc的词法分析器+语法分析器