Count Unique Characters of All Substrings of a Given String | Leetcode 828

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024
  • This video explains a very important interview problem which is to Count Unique Characters of All Substrings of a Given String. This problem is a common Amazon, Microsoft interview problem. It is based on counting unique characters in all substrings of a string.
    CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
    ======================================PLEASE DONATE=============================
    🧡 SUPPORT OUR WORK: / techdose
    💚 UPI-ID: surya.kahar@ybl
    💞JOIN Membership: / @techdose4u
    ==============================================================================
    INSTAGRAM : / surya.pratap.k
    LinkedIn: / surya-pratap-kahar-47b...
    WEBSITE: techdose.co.in/
    TELEGRAM Channel LINK: t.me/codewithT...
    TELEGRAM Group LINK: t.me/joinchat/...
    =======================================================================
    USEFUL LINKS:
    🟠Must do TIPS to ACE Virtual Interview: • 🔴Must do Tips to ACE y...
    🟢Best strategy to excel your coding interview: • 🔴Best strategy to exce...
    🟡Get your dream job in 1 month: • 🔴Get your dream job in...
    🔵How to crack dream job in just 2 months: • How to crack dream job...
    🟣7 Days DSA plan: techdose.co.in...
    RELATED LINKS:
    CODE LINK: gist.github.co...

ความคิดเห็น • 26

  • @anuragkhugshal7792
    @anuragkhugshal7792 ปีที่แล้ว +10

    After struggling for hours with text solutions, finally understood it from this beautiful explanation.

  • @akhilkumarp
    @akhilkumarp 2 ปีที่แล้ว +7

    Very good and planned explanation., Understood in a shot

  • @lapujain
    @lapujain 7 หลายเดือนก่อน

    Your teaching style is awesome. Keep up the good work.

  • @mdaasil2329
    @mdaasil2329 9 หลายเดือนก่อน

    Very well explained! Thanks TechDose.

  • @RajiurRahman1
    @RajiurRahman1 6 หลายเดือนก่อน

    Thank you, your explanation was very easy to understand. You made a difficult problem somewhat easy, at least "medium".

  • @tien556
    @tien556 7 หลายเดือนก่อน

    This is a master piece thank you so much!

  • @phantom3612
    @phantom3612 14 วันที่ผ่านมา

    idea is:
    Find contribution of each char in string
    eg. ABCABDA
    here we see A at starting: putting A in middle
    Check LHS size = 1 & RHS side (as long as A is unique) 4
    Doing 1*4 = 4 (gives contribution of first A)
    Similarlily, do rest all chars and add up at the end!
    How do we know this? Observation & Dry run to check!
    -----------------------------------------------
    Approach---
    Create a MAP (for constant time lookup) of vector of occurence
    A-> 0-3-6
    B-> 1-4
    C-> 2
    D-> 5
    Now, do add -1 before each vec and n after each vec in map
    So that when we check for each occurence (since we know index)
    we can do e.g.[0], 0-(-1) * (3-0) = 1
    and for [6], (6-3)* (n-6) = 3*1 = 3
    and [3], (3-0)*(6-3) = 3*3 = 9
    ADDING UP, 1+3+9 = 13

  • @himaniupadhyay8201
    @himaniupadhyay8201 9 หลายเดือนก่อน

    Best Explanation with intution

  • @mrinalkumar9453
    @mrinalkumar9453 ปีที่แล้ว

    Wonderful explanation❤

  • @zz-oq2dt
    @zz-oq2dt ปีที่แล้ว +1

    very smart!!!😀

  • @priyadarshinir9730
    @priyadarshinir9730 2 ปีที่แล้ว

    Very Good Explanation!
    how's the time complexity O(N)?
    we have a list of list and for each list we count.
    isn't it a time complexity near to O(N^2)?

    • @ash7130
      @ash7130 ปีที่แล้ว

      He is using the list of lists where the first list size is fixed to 26 alphabets, thus a constant. The only time required is to traverse the inner list whose worst case is 'len_of_string', i.e. O(n).

  • @shashirajraja
    @shashirajraja 2 ปีที่แล้ว

    Nice Explanation!!

  • @riteshsingh7067
    @riteshsingh7067 2 ปีที่แล้ว +1

    Is interview prep course still live?

    • @techdose4u
      @techdose4u  2 ปีที่แล้ว +1

      Yes

    • @RahulKumar-be3lq
      @RahulKumar-be3lq 2 ปีที่แล้ว +1

      @@techdose4u Congratulations, for AIR 1 in google kick-start round D

    • @factswithabhi27
      @factswithabhi27 2 ปีที่แล้ว

      @@techdose4u when the new batch get starting?

  • @pironobcoding
    @pironobcoding 2 ปีที่แล้ว +2

    back after so long

  • @wilfredomartel7781
    @wilfredomartel7781 2 ปีที่แล้ว +2

    👏👏

  • @danielaviv8215
    @danielaviv8215 2 ปีที่แล้ว

    what is the name of the software you are using?

  • @hhcdghjjgsdrt235
    @hhcdghjjgsdrt235 2 ปีที่แล้ว

    Avoid Flood In The City
    please please please
    explain this problem
    why everyone is getting TLE ?
    please please please

  • @cunghocthuattoan7869
    @cunghocthuattoan7869 2 ปีที่แล้ว

    Thank you so much! Very well explained!