
Asked in Freshworks
Middle of Linked List Problem Statement
Given the head node of a singly linked list, return a pointer pointing to the middle node of the linked list. In case the count of elements is even, return the node which is further from the head.
Example:
Input:
1 -> 2 -> 3 -> 4 -> null
Output:
Pointer to node with value 3
Explanation:
The linked list has 4 elements, so we return the second of the two middle elements (i.e., node with value 3) as it is further from the head node.
Constraints:
1 <= T <= 50
1 <= N <= 4*104
-109 <= data <= 109
- The linked list nodes must not contain the value -1 (used only as a sentinel value for input parsing).
- Time Limit: 1 sec
Note:
- You do not need to print anything; just implement the function and return the answer.
- For a linked list with only one node, the head node itself is the middle.
- If no midpoint exists, return a null pointer.

AnswerBot
4mo
Return the middle node of a singly linked list, or the second middle node if count is even.
Traverse the linked list with two pointers, one moving twice as fast as the other
When the fast pointer reache...read more
Help your peers!
Add answer anonymously...
Top Senior Software Developer Interview Questions Asked at Freshworks
Q. What is threading, and what are the different scheduling algorithms?
Q. Cube Sum Pairs Problem Statement Given a positive integer N, find the number of ...read more
Q. Can you discuss the low-level design (LLD) of a system similar to Flipkart?
Interview Questions Asked to Senior Software Developer at Other Companies
Top Skill-Based Questions for Freshworks Senior Software Developer
Web Development Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Algorithms Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

