当前位置:网站首页>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];
}
}
边栏推荐
- [uniapp] uniapp development app online Preview PDF file
- repeat_P1002 [NOIP2002 普及组] 过河卒_dp
- DeFi生态NFT流动性挖矿系统开发搭建
- Scala基础教程--19--Actor
- 2022CoCa: Contrastive Captioners are Image-Text Fountion Models
- php伪原创api对接方法
- Unity给自己的脚本添加类似编辑器扩展的功能案例ContextMenu的使用
- [发布] 一个测试 WebService 和数据库连接的工具 - DBTest v1.0
- Caché WebSocket
- 神经网络物联网平台搭建(物联网平台搭建实战教程)
猜你喜欢

中国农科院基因组所汪鸿儒课题组诚邀加入

What if the self incrementing ID of online MySQL is exhausted?

整理混乱的头文件,我用include what you use

Angry bird design based on unity
![[release] a tool for testing WebService and database connection - dbtest v1.0](/img/4e/4154fec22035725d6c7aecd3371b05.jpg)
[release] a tool for testing WebService and database connection - dbtest v1.0

Torchdrug tutorial

Go microservice (II) - detailed introduction to protobuf

1、 Introduction to C language

【uniapp】uniapp开发app在线预览pdf文件

Scala基础教程--17--集合
随机推荐
My colleagues quietly told me that flying Book notification can still play like this
The CDC of sqlserver can read the data for the first time, but it can't read the data after adding, deleting and modifying. What's the reason
英特尔集成光电研究最新进展推动共封装光学和光互连技术进步
Caché WebSocket
C#实现定义一套中间SQL可以跨库执行的SQL语句(案例详解)
奥迪AUDI EDI INVOIC发票报文详解
神经网络物联网应用技术就业前景【欢迎补充】
1672. 最富有客户的资产总量
发送和接收IBM WebSphere MQ消息
神经网络物联网平台搭建(物联网平台搭建实战教程)
Other InterSystems%net tools
Installation and use of VMware Tools and open VM tools: solve the problems of incomplete screen and unable to transfer files of virtual machines
大佬们,求助一下,我用mysql cdc 2.2.1(flink 1.14.5)写入kafka,设置
C # implementation defines a set of SQL statements that can be executed across databases in the middle of SQL (detailed explanation of the case)
Torchdrug tutorial
小发猫物联网平台搭建与应用模型
Technology sharing | interface testing value and system
激进技术派 vs 项目保守派的微服务架构之争
数组中的第K个最大元素
一种将Tree-LSTM的强化学习用于连接顺序选择的方法