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

Поділитися
Вставка
  • Опубліковано 20 гру 2024

КОМЕНТАРІ • 19

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

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

  • @MB-hn5qk
    @MB-hn5qk 7 місяців тому +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 7 місяців тому

      exactly

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

      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

    • @SrishtiJaiswal-v5m
      @SrishtiJaiswal-v5m 6 місяців тому

      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 5 місяців тому

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

    • @vinayaksinghal
      @vinayaksinghal 5 місяців тому

      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

  • @ARYANMITTAL
    @ARYANMITTAL  7 місяців тому +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 ❤

  • @maddycoder1294
    @maddycoder1294 7 місяців тому

    very good explanation

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

    well explained!

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

    👍👍

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

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

    • @bhuvanak4157
      @bhuvanak4157 7 місяців тому

      could you please share the code

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

      @@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 7 місяців тому

      Me too😅

    • @vinayaksinghal
      @vinayaksinghal 5 місяців тому

      @@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 7 місяців тому

    very well

  • @monilcharola6873
    @monilcharola6873 7 місяців тому

    :)

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

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