Middle of linked list leetcode C++ | Leetcode 876 |Tortoise and Hare Approach | Interview Bit

preview_player
Показать описание
Middle of linked list leetcode C++ | Leetcode 876 |Tortoise and Hare Approach | Interview Bit

Hi
Welcome To our channel Code Bashers.

About Video:
This video is about finding the middle of the linked list. The approach that is used in this video is Hare and tortoise approach. watch the video for edxplanation.

Queries solved in this video:
1)What is middle of linked list.
2)Explanation of how to find middle of linked list through examples.
3)Approach of finding the middle element of linked list.
4)Code for finding the middle element in c++ of linked list.

See video for explanation with example and dry run.

Complexity Analysis:
Time Complexity : O(N)
Space Complexity : O(1)

#codinginterview #placementquestion #leetcode #linkedlist #code

Please Like , Share , Subscribe and forward it to your friends.

Thank You

More Linked List Videos:

Merge two sorted linked list leetcode | Leetcode 21 | Inplace Solution | O(1) space Complexity :

Add two numbers represented by linked lists leetcode | Leetcode 2 | (Approach + code) in C++ :

Remove Nth Node From End of List Leetcode | Leetcode 19 | Single Pass Solution :

Delete Node in a Linked List Leetcode | Leetcode 237 | O(1) Solution

Intersection of Two Linked Lists Leetcode | Leetcode 160 | Approach + Code | C++

Rotate List Leetcode | Leetcode 61 | Leetcode October Challenge

Linked list cycle Approach | Leetcode 141 | easily explained both O(N) and O(1) space approach

Linked List Cycle 2 | Leetcode 142 | O(N) space and O(1) space Approaches

Reverse Linked List Leetcode | Leetcode 206 | Iterative Approach :
Рекомендации по теме
Комментарии
Автор

sir we are only check fast pointer which will increase by 2x thats why time complesity will be O(n/2)
thanks for this awesome approch

shubhamsonawane
Автор

why the condition is (fast != NULL && fast->next != NULL) and not (fast != NULL || fast ->next != NULL)
*have this doubt for very long. hope you clear it*

sumitpd
visit shbcf.ru