LeetCode 1657. Determine if Two Strings Are Close - Interview Prep Ep 100

Поделиться
HTML-код
  • Опубликовано: 18 сен 2024
  • ⭐ Shop on Amazon to support me: www.amazon.com...
    ⭐ NordVPN to protect your online privacy: go.nordvpn.net...
    ⭐ NordPass to help manage all of your passwords: go.nordpass.io...
    Problem link: leetcode.com/p...
    ⭐ Support my channel and connect with me:
    / @fishercoder
    Algorithm:
    Based on the definition of the two given operations, we can infer these:
    1. the order of each of the letter in the two words doesn't matter any more;
    2. we need to make sure all unique characters that appear in word1 does also appear in word2.
    // TOOLS THAT I USE:
    ○ Memory Foam Set Keyboard Wrist Rest Pad - amzn.to/3cOGOAj
    ○ Electric Height Adjustable Standing Desk - amzn.to/2S9YexJ
    ○ Apple Magic Keyboard (Wireless, Rechargable) - amzn.to/36gy5FJ
    ○ Apple Magic Trackpad 2 (Wireless, Rechargable) - amzn.to/36ltimu
    ○ Apple MacBook Pro - amzn.to/30iSvKE
    ○ All-In One Printer - amzn.to/34etmSi
    ○ Apple AirPods Pro - amzn.to/2GpVYQf
    ○ My new favorite Apple Watch - amzn.to/2EIIUFd
    // MY FAVORITE BOOKS:
    ○ Introduction to Algorithms - amzn.to/36hxHXD
    ○ Designing Data-Intensive Applications - amzn.to/2S7snOg
    ○ Head First Java - amzn.to/2ScLDKa
    ○ Design Patterns - amzn.to/2SaGeU2
    Follow me on Github for more LeetCode solutions: github.com/fis...
    Support me on Patreon: / fishercoder
    My ENTIRE Programming Equipment and Computer Science Bookshelf:
    www.amazon.com...
    And make sure you subscribe to my channel before you leave!
    Your comments/thoughts/questions/advice will be greatly appreciated!
    #softwareengineering #leetcode #algorithms #coding #interview #SDE #SWE #SiliconValley #programming #datastructures

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

  • @siddharthgupta848
    @siddharthgupta848 3 года назад +5

    keep producing these leetcode videos daily, it is really so valuable.Thanks

  • @varunpalsingh3822
    @varunpalsingh3822 8 месяцев назад +3

    you way of explanation is good

  • @kevinmanuel6711
    @kevinmanuel6711 3 года назад +2

    This is brilliant!

  • @NikolayMishin
    @NikolayMishin Год назад +1

    cool explanation, thank you!

  • @Meenereem
    @Meenereem 10 месяцев назад +1

    Thank you!

  • @amintalukder7189
    @amintalukder7189 Год назад +1

    I did not understand why count1 and count2 should be equal here ? they sometimes can not be equal, is not it ?

    • @mhmd5ld81
      @mhmd5ld81 Год назад

      I think because u r mapping characters by their frequency for example if I got 3 "a" in word1 and I got 3 "z" in word2, 'a' is at the first of the list word1 and z is at the bottom of the list word2 so we want to perform the 2 operations and in order to do that we need to check the equality of frequent chars so we need to sort each list and comparing them and yes the two count lists could not be equal and that misses with the 2 operations so we return false

  • @abdulmziya748
    @abdulmziya748 2 месяца назад

    Is there a way to solve this at linear time if we use a hashmap?