1930. Unique Length-3 Palindromic Subsequences | leetcode daily challenge | dsa | shashcode

Поделиться
HTML-код
  • Опубликовано: 5 янв 2025

Комментарии •

  • @shashwat_tiwari_st
    @shashwat_tiwari_st  2 дня назад +2

    Yr thoda khurafati idea aya hai just abhi.. ye try krke btao ki work kr rha hai ya ni and time complexity kya hai.
    Inner loop me set use kr rhe hai na (left+1, right-1) ke beech unique elements find krne ke kiye. Uski jagha prefix sum array use kro, unique so far calculate krne ke liye.
    ex: "aabca"
    prefix array: 1, 1, 2 , 3, 3
    ha ye array bnane ke liye bhi set ka logic use krna pdega but woh Iteration bach jaega (left+1, right-1).
    Loop ki jagha ye try kro prefix[right-1] - prefix[left], edge case dekhna shayd handle krna pde..
    Mai travel kr rha hu laptop ni hai pass me, solve krke btao!!

    • @aayushvbw
      @aayushvbw 2 дня назад

      I tried this out and found that the prefix array will only give the unique element count; it will leave out the possibility of a subsequence like 'aaa

  • @shashwat_tiwari_st
    @shashwat_tiwari_st  2 дня назад +5

    like target is 150. Please do like if you have understood the explanation as well as the code

  • @sanatan_0709
    @sanatan_0709 2 дня назад

    really insane logic appreciated man cool!!!

  • @nileshchandra3317
    @nileshchandra3317 2 дня назад +4

    mast dimaag yaar pta nhi hum kb soch payenge..

  • @untold_vlogs_09
    @untold_vlogs_09 2 дня назад

    amazing explanation

  • @nishith5380
    @nishith5380 2 дня назад +1

    bro keep doing..one day we will be very Big