filmov
tv
Finding middle element in a linked list| GeeksForGeeks| Problem of the Day | Java| Easy Solution
![preview_player](https://i.ytimg.com/vi/yLSVrRySeKE/maxresdefault.jpg)
Показать описание
In this question I have solved gfg problem of the day using very simple and easy to understand approach.
-----------------------------------------------------------------------------------------------------------------------
Finding middle element in a linked list
Given a singly linked list of N nodes.
The task is to find the middle of the linked list. For example, if the linked list is
1-2-3-4-5, then the middle node of the list is 3.
If there are two middle nodes(in case, when N is even), print the second middle element.
For example, if the linked list given is 1--2--3--4--5--6, then the middle node of the list is 4.
Example 1:
Input:
LinkedList: 1--2--3--4--5
Output: 3
Explanation:
Middle of linked list is 3.
Example 2:
Input:
LinkedList: 2--4--6--7--5--1
Output: 7
Explanation:
Middle of linked list is 7.
-------------------------------------------------------------------------------------------------------------------
***************************************************************************
#dsa #programming #gfg #gfgpotd #problemsolving #coding #softwareengineer #faang #competitiveprogramming #dsasheet #interviewpreparation #coding #gfg #geeksforgeeks #leetcode #potd #coding #india #easyexplaination #leetcode #leetcodechallenge #leetcodedailychallenge
#java #codinginterviews #problemoftheday #algorithm #datastructures #hindi #bitmanipulation #bits #competitiveprogramming
-----------------------------------------------------------------------------------------------------------------------
Finding middle element in a linked list
Given a singly linked list of N nodes.
The task is to find the middle of the linked list. For example, if the linked list is
1-2-3-4-5, then the middle node of the list is 3.
If there are two middle nodes(in case, when N is even), print the second middle element.
For example, if the linked list given is 1--2--3--4--5--6, then the middle node of the list is 4.
Example 1:
Input:
LinkedList: 1--2--3--4--5
Output: 3
Explanation:
Middle of linked list is 3.
Example 2:
Input:
LinkedList: 2--4--6--7--5--1
Output: 7
Explanation:
Middle of linked list is 7.
-------------------------------------------------------------------------------------------------------------------
***************************************************************************
#dsa #programming #gfg #gfgpotd #problemsolving #coding #softwareengineer #faang #competitiveprogramming #dsasheet #interviewpreparation #coding #gfg #geeksforgeeks #leetcode #potd #coding #india #easyexplaination #leetcode #leetcodechallenge #leetcodedailychallenge
#java #codinginterviews #problemoftheday #algorithm #datastructures #hindi #bitmanipulation #bits #competitiveprogramming
Комментарии