Check for Palindrome | Data Structures & Algorithms

Поділитися
Вставка
  • Опубліковано 7 лип 2024
  • Join Jomaclass for full-length videos like this: joma.tech/dsa

КОМЕНТАРІ • 27

  • @debasishphukon5345
    @debasishphukon5345 3 роки тому

    Please keep posting this is some amazing content right here

  • @pedroalonsoms
    @pedroalonsoms 3 роки тому

    great video thanks

  • @qqq1234x
    @qqq1234x 3 роки тому

    Thanks jomaoppa :)

  • @muhammadhashir7949
    @muhammadhashir7949 3 роки тому +1

    Sir I love your videos I'm from Pakistan.exited for your next video on your main channel

  • @RecursiveLoops
    @RecursiveLoops 3 роки тому +5

    Technically the correct time complexity is Θ(n).
    Reading the input string requires Θ(n) and reading the dictionary requires O(n).
    Θ(n) + O(n) = Θ(n)
    I'm not opinionated, but if you state that this algorithm runs in O(n) it means that the worst case is linear; this implies the existence of some cases where the algorithm runs better, but it is not true because the reading of the input string defines the algorithm's lower bound in terms of time complexity.
    In any case great video and I wish you the best of luck with your new project :)

    • @doboy
      @doboy 3 роки тому +2

      It's both, everything that is Θ(n) is also O(n) but not vice versa.

    • @RecursiveLoops
      @RecursiveLoops 3 роки тому +2

      Zack Do yes, but one of them is simply more precise :)
      In this case it's easy to calculate Big Theta and gives more information about the time complexity.
      I know that Big O is more mainstream than Big Theta...

    • @aadityabhetuwal5990
      @aadityabhetuwal5990 3 роки тому +1

      it' not gonna be O(n) if you use set() because it removes all duplicates and iteration can be performed in n/2 + 1 passes for the worst case.

  • @samuelemerlin
    @samuelemerlin 3 роки тому +1

    This was the first problem I solved with Python 💪

  • @YiTseng
    @YiTseng 3 роки тому +2

    6:45
    Joma: imagine if I had another odd number....
    Me: (think K...)
    Joma: for example like K....
    Me: what!?

  • @aadityabhetuwal5990
    @aadityabhetuwal5990 3 роки тому

    easy python solution using itertools:
    import itertools as it
    def find_palindrome(st):

    st = st.lower()
    x = list(it.permutations(st, len(st)))

    for i in x:
    s1 = "".join(i)
    flag = False

    if s1 == s1[::-1] :
    return s1
    return False

    print(find_palindrome( input() ))

  • @SunsetRacer
    @SunsetRacer 3 роки тому +1

    Now joma being a ronin. There is no more naniiiii😒

  • @wettaco6938
    @wettaco6938 3 роки тому

    Question : why can't we just reverse the string and test if the reversed version = string ?

    • @devinh.9683
      @devinh.9683 3 роки тому +2

      because they will give you strings that could be palindrome, but not currently a palindrome. This solution will work only if the string they give you is currently a palindrome.

  • @colinking73
    @colinking73 3 роки тому

    Puh-linndrahm

  • @hugelevin
    @hugelevin 3 роки тому

    Can you provide a simplified Java code version of this exercise? I have managed to do it using HashMap but have a lot of code while yours seems so simple. Thanks.

  • @aryaman_godara
    @aryaman_godara 3 роки тому

    qqaao ... we can make pa;indrome , bro are you sick or am i hogh too much ???

  • @bridgegolden238
    @bridgegolden238 3 роки тому

    what happened to the old logo 😭

  • @whistletoe
    @whistletoe 3 роки тому +1

    Why can’t qqaao be made into a palindrome? Like qaoaq?

    • @JomaClass
      @JomaClass  3 роки тому +2

      The example was qqaaao, not qqaao

    • @whistletoe
      @whistletoe 3 роки тому +1

      Joma Class Oooh sorry my screen was too small lmao

  • @hectorsvill
    @hectorsvill 3 роки тому

    😄

  • @KuaisArts
    @KuaisArts 3 роки тому +2

    great video but the way you say palindrome tho...

  • @rudraprasaddash3809
    @rudraprasaddash3809 3 роки тому +1

    How about this:-
    def isPalindrome(s):
    If (s==s[::-1]):
    return True
    return False
    🤔🤔

    • @JomaClass
      @JomaClass  3 роки тому

      The question asks if a string can be rearranged to BE a palindrome. It doesn’t just check if it’s a palindrome.
      So for example, “dda” should return true because it can be rearranged to “dad”

    • @rudraprasaddash3809
      @rudraprasaddash3809 3 роки тому

      @@JomaClass o...oh, domo🙇. Nice solution