Leetcode - Intersection of Two Arrays II (Python)

Поділитися
Вставка
  • Опубліковано 25 сер 2024
  • September 2021 Leetcode Challenge
    Leetcode - Intersection of Two Arrays II #350
    Difficulty: Easy

КОМЕНТАРІ • 14

  • @Mrkichanpark
    @Mrkichanpark 2 роки тому +15

    how do you just know what to do?

  • @RicardoBuquet
    @RicardoBuquet 2 роки тому +1

    how does the sorting affects the Big O of this algo?

  • @minciNashu
    @minciNashu 2 роки тому +1

    This can be done in O(n), without sorting.

  • @leetcode650
    @leetcode650 8 місяців тому

    Why are u not checking if key is there in the map or not it should raise key error right but why it is not happening

  • @anastasiazrh1455
    @anastasiazrh1455 2 роки тому +1

    isn't the space complexity here O(n+m) as well (like the time complexity) since we have the Counter object and the output list?

  • @janmichaelaustria620
    @janmichaelaustria620 2 роки тому +1

    The word intersection threw me off for the longest time >.

  • @apoorvsinghnegi6729
    @apoorvsinghnegi6729 Рік тому

    Why do we need to increment i pointer in case nums[i] is smaller than nums[j] and vice -versa

    • @varuntyagi9610
      @varuntyagi9610 Рік тому

      because in case of sorted arrays if nums1[i] < nums2[j] then we are certain that nums1[i] is not in nums2 so it is safe to move on to the next element in nums1 hence i += 1.

  • @piyush6631
    @piyush6631 2 роки тому

    What is Counter refering to?

    • @percyjackson1662
      @percyjackson1662 2 роки тому +6

      Counter will give you Counter object containing distinct elements of list as keys and count of those elements as values.
      c = Counter([1,2,2,1])
      output: Counter({1: 2, 2: 2})

  • @CEOofTheHood
    @CEOofTheHood 2 роки тому +1

    From what I can deduce from the background of your videos, you go to the office once a week the rest is remote. Hahaha. I have too much time on my hands lol. I'm sure I'm wildly off.

  • @jacobdumas6529
    @jacobdumas6529 2 роки тому

    thank greats explanations