Check for Palindrome | Data Structures & Algorithms

Поділитися
Вставка
  • Опубліковано 25 лис 2024

КОМЕНТАРІ • 27

  • @RecursiveLoops
    @RecursiveLoops 4 роки тому +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 4 роки тому +2

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

    • @RecursiveLoops
      @RecursiveLoops 4 роки тому +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.

  • @YiTseng
    @YiTseng 4 роки тому +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() ))

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

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

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

    Please keep posting this is some amazing content right here

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

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

    • @devinh.9683
      @devinh.9683 4 роки тому +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.

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

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

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

    This was the first problem I solved with Python 💪

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

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

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

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

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

      The example was qqaaao, not qqaao

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

      Joma Class Oooh sorry my screen was too small lmao

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

    great video thanks

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

    what happened to the old logo 😭

  • @ws_zilch
    @ws_zilch 4 роки тому

    Thanks jomaoppa :)

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

    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.

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

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

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

    Puh-linndrahm

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

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

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

      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 4 роки тому

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

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

    😄