?? Day #45 of My 365 Days Coding Challenge!

?? Day #45 of My 365 Days Coding Challenge!

?? A Personal Reflection:

Palindromes have always fascinated me—whether it’s words like "madam" or numbers like 121. But have you ever checked if a linked list is a palindrome? ?? Today, I implemented a function to check if a linked list reads the same forward and backward!


?? What I Did Today:

I used Floyd’s Tortoise and Hare Algorithm ???? to find the middle of the linked list, then reversed the second half and compared both halves for a match.


?? Key Learning:

  • Floyd’s Algorithm (Fast & Slow Pointer) finds the middle efficiently (O(n)).
  • Reversing a Linked List helps in comparing both halves.
  • Time Complexity: O(n), Space Complexity: O(1) (in-place reversal).


? Extra Touch:

? Handles even and odd-length lists

? No extra space used (modifies the list temporarily)

? Can be extended to restore the original list after checking!


?? Your Turn:

Modify this to restore the original linked list after checking for a palindrome!


#365DaysOfCode #CodingChallenge #PalindromeCheck

要查看或添加评论,请登录

Harsh Pandhe的更多文章

  • ?? Day #60 of My 365 Days Coding Challenge!

    ?? Day #60 of My 365 Days Coding Challenge!

    ?? A Personal Reflection: A Power Set sounds like something out of a superhero movie, but in reality, it's an essential…

  • ?? Day #59 of My 365 Days Coding Challenge!

    ?? Day #59 of My 365 Days Coding Challenge!

    ?? A Personal Reflection: Sorting algorithms are like problem-solving strategies—some take their time, while others…

    1 条评论
  • ?? Day #58 of My 365 Days Coding Challenge!

    ?? Day #58 of My 365 Days Coding Challenge!

    ?? A Personal Reflection: Sorting can be slow, but what if we divide and conquer? That's the beauty of Merge Sort—it…

  • ?? Day #57 of My 365 Days Coding Challenge!

    ?? Day #57 of My 365 Days Coding Challenge!

    ?? A Personal Reflection: Sorting is like arranging playing cards in your hand—you pick up each card and insert it in…

  • ?? Day #56 of My 365 Days Coding Challenge!

    ?? Day #56 of My 365 Days Coding Challenge!

    ?? A Personal Reflection: Sorting is like choosing the best player for a team—you look for the best candidate and place…

  • ?? Day #55 of My 365 Days Coding Challenge!

    ?? Day #55 of My 365 Days Coding Challenge!

    ?? A Personal Reflection: Sorting is like organizing a messy room—sometimes, the simplest approach is to swap things…

  • ?? Day #54 of My 365 Days Coding Challenge!

    ?? Day #54 of My 365 Days Coding Challenge!

    ?? A Personal Reflection: Ever been in a crowded room where one person stands out? In a string, the first non-repeating…

  • ?? Day #53 of My 365 Days Coding Challenge!

    ?? Day #53 of My 365 Days Coding Challenge!

    ?? A Personal Reflection: Ever tried a circular queue in real life? Think of people standing in a line, and the first…

  • ?? Day #52 of My 365 Days Coding Challenge!

    ?? Day #52 of My 365 Days Coding Challenge!

    ?? A Personal Reflection: Imagine having a row of numbered lockers, but one is missing. You could check each one…

  • ?? Day #51 of My 365 Days Coding Challenge!

    ?? Day #51 of My 365 Days Coding Challenge!

    ?? A Personal Reflection: Ever tried opening a box, only to find another box inside..

其他会员也浏览了