125 . Valid Palindrome || LeetCode Placement Series || Explained in HINDI

Поділитися
Вставка
  • Опубліковано 18 вер 2024
  • Instagram link:- / reelcoding
    Don't click:- / @reelcoding
    Sheet link:- www.techinterv...
    Approach 1:-
    Clean the Input String:
    Initialize a StringBuilder to store the cleaned version of the input string.
    Iterate through each character in the input string.
    If the character is alphanumeric, convert it to lowercase and append it to the StringBuilder.
    Check for Palindrome:
    Convert the StringBuilder to a string (cleanedStr).
    Reverse the StringBuilder and convert it to another string (reversedStr).
    Compare the two strings to check if they are equal.
    Return the Result:
    If the cleaned string is equal to its reversed version, return true indicating the input string is a palindrome. Otherwise, return false.
    Time Complexity
    O(n): The function makes a single pass through the input string to clean it, and another pass to check if the cleaned string is a palindrome.
    Space Complexity
    O(n): The solution uses extra space proportional to the length of the input string for storing the cleaned string.
    Approach 2:-
    Initialize Pointers:
    Set left pointer at the start of the string.
    Set right pointer at the end of the string.
    Traverse the String:
    Use a while loop to move the pointers towards the center.
    Skip non-alphanumeric characters by incrementing the left pointer and decrementing the right pointer accordingly.
    Compare the characters at the left and right pointers.
    If they don't match, return false.
    If they match, move both pointers inward.
    Return the Result:
    If the loop completes without finding a mismatch, return true indicating the input string is a palindrome.
    Time Complexity
    O(n): The function makes a single pass through the string, with each character processed at most once.
    Space Complexity
    O(1): The solution uses a constant amount of extra space.
    Whether you're new to problem-solving or seeking insights into Java programming techniques, this video offers valuable insights into tackling similar challenges effectively.
    Do join with me guys for problem solving on LeetCode.
    Please like and subscribe this channel and share among your friends, it helps me to motivate and bring more videos for you guys. ❤️❤️
    Soon, DSA batch (Hinglish) is going to launch on this channel. So, do subscribe so that you will get the notification for all new videos.👍👍🔔🔔.
    Do comment if any doubts left. Thank you 😊
    #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa
    #CodingExplanation #AlgorithmTutorial #JavaProgramming #DataStructures #DynamicProgramming #CodeExplanation #ProgrammingTutorial #AlgorithmExplanation #TechTutorial #LearnToCode #ProblemSolving #ProgrammingConcepts #SoftwareDevelopment #TechEducation #CodingCommunity #CodeBreakdown #ComputerScience
    #JavaTutorial #AlgorithmAnalysis #EducationalContent
    125 . Valid Palindrome
    Leetcode 125
    Valid Palindrome
    Leetcode daily challenge
    Leetcode potd
    125 Valid Palindrome
    leetcode potd today solution
    leetcode potd today
    leetcode grind
    leetcode questions for interview
    leetcode series
    leetcode hindi
    placement series

КОМЕНТАРІ • 2

  • @hamudxd9497
    @hamudxd9497 Місяць тому +1

    Followed you only for dsa but please do it on javascript

  • @reelcoding
    @reelcoding  Місяць тому

    Code link:- leetcode.com/problems/valid-palindrome/solutions/5561907/java-solution-explained-in-hindi-2-approaches/