3132 & 3131 Find the Integer Added to Array II | 3131. Find the Integer Added to Array I

Поділитися
Вставка
  • Опубліковано 26 сер 2024
  • In this video, I'll talk about how to solve Leetcode 3132 & 3131 Find the Integer Added to Array II | 3131. Find the Integer Added to Array I
    Let's Connect:
    📱Discord (Join Community) : / discord
    📝Linkedin: / aryan-mittal-0077
    📸 Instagram: / ez.pz.dsa
    💻 Twitter - / aryan_mittal007
    🤖 Github: github.com/ary...
    About Me:
    I am Aryan Mittal - A Software Engineer in Goldman Sachs, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)
    ✨ Hashtags ✨
    #programming #Interviews #leetcode #faang #maang #datastructures #algorithms

КОМЕНТАРІ • 19

  • @HimanshuYadav-pp2ue
    @HimanshuYadav-pp2ue 3 місяці тому +3

    because of you i can easily and consistently upsolving the contest love your consistency

  • @MB-hn5qk
    @MB-hn5qk 4 місяці тому +6

    In the first brute force approach of the Second problem, wouldn't the TC be O(n^3) instead of O(n^2)? Because rechecking for the diff would be O(n) too, not O(1). Because, after removing 2 elements from nums1, we would need to check the validity of the difference throughout the arrays (modified nums1 and nums2), as the diff could be inconsistent for some cases of removing 2 elements from nums1. Nice Explanation BTW!

    • @gauravagrawal7988
      @gauravagrawal7988 3 місяці тому

      exactly

    • @pranavreddy-do9ck
      @pranavreddy-do9ck 3 місяці тому

      since you have sorted it taking diff would be O(1) only because, suppose consider 1st array of size 5 and 2nd array of size 3 now ,if you remove 1st and 3rd element of 1st array you could directly take diff nums2[0] - nums1[1] 2nd element and keep on checking min of diff throught O(n^2) iterations

    • @user-wj5jt6zf8h
      @user-wj5jt6zf8h 3 місяці тому

      Firstly I thought the same generating all pair in o(n2) then for checking the diff in o(n) make it o(n3)
      But no need to generate pair as element are sorted check for single element only and number of same diff should be greater than or equal to num2.size then in similar fashion check for each element make it o(n2)
      And he further optimize it in o(3n) by taking element first second and 3rd only

    • @vinayaksinghal
      @vinayaksinghal Місяць тому

      @@pranavreddy-do9ck no bro, we would have to go through it all only

    • @vinayaksinghal
      @vinayaksinghal Місяць тому

      yes, exactly
      class Solution {
      private:
      int solve(vector& nums1, vector& nums2){
      int n=nums1.size();
      int m=nums2.size();
      int i=0;
      int j=0;
      while(nums1[j]==-1){
      j++;
      }
      int ans=nums2[i]-nums1[j];
      j++;
      i++;
      while(i

  • @apputadhiyal9451
    @apputadhiyal9451 4 місяці тому +1

    well explained!

  • @maddycoder1294
    @maddycoder1294 4 місяці тому

    very good explanation

  • @nikhillasinkar2233
    @nikhillasinkar2233 4 місяці тому +1

    👍👍

  • @ujjwalrockriser
    @ujjwalrockriser 4 місяці тому +1

    I solved 2nd using O (n ^ 3) brute force of brute force approach 😂 and It worked too 😂

    • @bhuvanak4157
      @bhuvanak4157 4 місяці тому

      could you please share the code

    • @YashMalav-kh1ov
      @YashMalav-kh1ov 4 місяці тому

      @@bhuvanak4157 int minimumAddedInteger(vector& nums1, vector& nums2) {
      int n = nums1.size();
      int m = nums2.size();
      sort(nums1.begin(),nums2.end());
      sort(nums2.begin(),nums2.end());
      int j=0;
      int ans = 1e9;
      int index = 0;
      int i = index;
      while(index

    • @shashanksahu9230
      @shashanksahu9230 3 місяці тому

      Me too😅

    • @vinayaksinghal
      @vinayaksinghal Місяць тому

      @@bhuvanak4157
      class Solution {
      private:
      int solve(vector& nums1, vector& nums2){
      int n=nums1.size();
      int m=nums2.size();
      int i=0;
      int j=0;
      while(nums1[j]==-1){
      j++;
      }
      int ans=nums2[i]-nums1[j];
      j++;
      i++;
      while(i

  • @goyaldeekshant
    @goyaldeekshant 4 місяці тому

    very well

  • @monilcharola6873
    @monilcharola6873 4 місяці тому

    :)

  • @ARYANMITTAL
    @ARYANMITTAL  4 місяці тому +2

    Problem3 of today's Contest - ua-cam.com/video/eA1xIDUqIDc/v-deo.html
    .
    Do make sure to join Discord for doubts, discussion & active problem Solving ❤

  • @YashMalav-kh1ov
    @YashMalav-kh1ov 4 місяці тому

    my 2nd part approach was just similar and even after so many bound and checks i got run time error🥲