TGViewer
Coding Interview Resources Coding Interview Resources @crackingthecodinginterview ยท 52.2K subscribers
Post #2958 1.19K
๐Ÿš€ 28. How do you implement a circular linked list?

In a circular linked list: Last node โ†’ points to head instead of NULL.

๐Ÿ”น Visualization 
1 โ†’ 2 โ†’ 3 
โ†‘       โ†“ 
โ† โ† โ† โ†

๐Ÿ”น Python Example
class Node:
  def init(self, data):
    self.data = data
    self.next = None

head = Node(1)
second = Node(2)
third = Node(3)

head.next = second
second.next = third
third.next = head

๐Ÿ”น Uses
โœ… Round-robin scheduling
โœ… Multiplayer games
โœ… Music playlists
โœ… CPU scheduling

๐Ÿš€ 29. How do you split a list into equal parts?

๐Ÿ”น Approach
1. Count total nodes
2. Divide length
3. Break links carefully

๐Ÿ”น Example
1 โ†’ 2 โ†’ 3 โ†’ 4 โ†’ 5 โ†’ 6

Split into 2 parts:
1 โ†’ 2 โ†’ 3
4 โ†’ 5 โ†’ 6

๐Ÿ”น Python Idea
length = count_nodes(head)
part_size = length // k
extra = length % k

Distribute remaining nodes one by one.

๐Ÿ”น Complexity
Time โ†’ O(n)
Space โ†’ O(1)

๐Ÿ”น Interview Tip
Frequently appears in partitioning problems.

๐Ÿš€ 30. How do you implement a doubly linked list?
A doubly linked list stores: prev pointer + next pointer

๐Ÿ”น Visualization
NULL โ† 1 โ‡„ 2 โ‡„ 3 โ†’ NULL

๐Ÿ”น Python Implementation
class Node:
  def init(self, data):
    self.data = data
    self.prev = None
    self.next = None

๐Ÿ”น Advantages
โœ… Bidirectional traversal
โœ… Easier deletion
โœ… Efficient backtracking

๐Ÿ”น Disadvantages
โŒ More memory
โŒ Extra pointer management

๐Ÿ”น Real-World Uses
โœ… Browser history
โœ… Undo/redo
โœ… Navigation systems
โœ… Music players

๐Ÿ”น Complexity
Insert/Delete โ†’ O(1)
Search โ†’ O(n)

๐Ÿ”ฅ Double Tap โค๏ธ For Part-4
  • โค 2
More from @crackingthecodinginterview
  1. Oct 7, 2026๐Ÿš€ DSA Topics Every Programmer Should Know ๐Ÿ’ป๐Ÿ”ฅ ๐Ÿ“ฆ 1. Arrays โœ” Traversal โœ” Searching โœ” Sorโ€ฆ
  2. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  3. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
  4. Sep 29, 2026โœ… Daily Coding Habits That Make You a Better Developer ๐Ÿง ๐Ÿ’ปโœจ 1๏ธโƒฃ Code Every Day (Even 30 Mโ€ฆ
  5. Sep 29, 2026๐—™๐—ฅ๐—˜๐—˜ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€ ๐—ง๐—ผ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—”๐—œ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ๐Ÿš€ โ€‹ Explore 6 free resourceโ€ฆ
  6. Sep 28, 2026Hereโ€™s a DSA problem-solving cheat sheet that will help you solve 90โ€“95% of questions thatโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’