First missing Positive | Programming Interview Preparation Must Do programming questions

Sdílet
Vložit
  • čas přidán 18. 11. 2022
  • 🟠 Problem link of First missing Positive: bit.ly/3Ec7tVN
    This is the video under the series of Must do Programming Questions. First missing Positive
    Join My Telegram channel for more Updates: telegram.me/helloworldbyprince
    complete DSA preparation: github.com/Prince-1501/Comple...
    ----------------------------------------------------------------------------------------
    *Follow me *
    LinkedIn► / iamprince
    Facebook► / helloworldofficials
    Instagram► / helloworldbyprince
    Twitter► / prince_king_
    Telegram► telegram.me/helloworldbyprince
    ----------------------------------------------------------------------------------------
    ►Our Playlists on:-
    🔥 Tree: • Tree Data Structure & ...
    🔥 Stack & Queue: • Stack & Queue Data Str...
    🔥 Hashing: • Hashing Data Structure...
    🔥 Graph: • Graph Data Structure &...
    🔥 Matrix: • Matrix (Multidimension...
    🔥 Heap: • Heap Data Structure & ...
    🔥 Linked List: • Linked List Data Struc...
    🔥 STL: • Standard Template Libr...
    🔥 Leetcode: • LeetCode Solutions And...
    🔥Competitive Programming: • Full course in Competi...
    🔥 C++ Full Course: • C++ full Course in HINDI
    🔥 Algorithms: • L-01 || Prefix Sum Arr...
    🔥 Data Structure: • Data Structures with C...
    ------------------------------------------------------------------------
    🌟 Please leave a LIKE ❤️ and SUBSCRIBE for more AMAZING content! 🌟
    ✨ Tags ✨
    Implement Heap from class c++
    K largest element
    K largest element min heap
    min-heap Delete operation in a heap
    Introduction to the heap data structure
    heap playlist Hello world
    heap practice problems
    heap practice problems gfg
    leetcode heap questions
    leetcode heap
    heap hello world
    Types of the heap in Data structure & algorithms
    playlist heap Hindi
    question asked in Google
    off-campus placement
    Practice heap data structure
    heap in a data structure in Hindi
    heap Full playlist for Beginners
    algorithms
    heap
    data structure
    gate computer science preparation
    programming languages
    Comment "#Princebhai" if you read this 😉😉
    #Heap #decreaseKey() #programming

Komentáře • 45

  • @djpsn7094
    @djpsn7094 Před rokem +8

    there is one edge case it won't work with duplicate value ex - [1, 1] you will mark 1 by -1 then you will go to second index then you will again do -1 * -1 then it will become 1 but we have to return 2 ans for that we can write one edge case if(arr[index]>0) {arr[index] *= -1 ; }

  • @manasuniyal2897
    @manasuniyal2897 Před rokem +1

    Prince bhaiya I am learning from your VIDEOS . Thank you very much
    Today I will definetely complete LINKED LIST series and tommorow TREES series .
    I am in third year . I have very less time left . I HOPE I will make it to a good company .
    As soon as I complete atleast basic DSA I will inform you about it .
    Once again thanks .
    I am also learning back end development NODE JS from youtube and as soon as I am confident in it and develop projects worth watching I will contact you for help.
    Thanks again , you are doing an amazing job for community .
    May god always keep you healthy.

  • @nihalkumardwivedi7229

    Great work ,keep going

  • @user-qv8gi7pb9v
    @user-qv8gi7pb9v Před 10 měsíci +12

    bhaiya faltu gyan mt chodo jo que.. h upr focus to achha hain , oversmart to aise bnte ho jese sunder pichai ko bhi aapne hi pdaya ho , baki pda achhe rhe ho bs aapki ye chiz irritate krti h

  • @naikajsevak6090
    @naikajsevak6090 Před rokem

    keep uploading this kind of video please we miss u bro

  • @AryanGupta-oy5it
    @AryanGupta-oy5it Před rokem +1

    It will be nums[index]=-1*abs(nums[index])

  • @mayankmehra4370
    @mayankmehra4370 Před rokem +2

    this code does not work in gfg !! fail to satisfy all test case .

  • @satyam2312
    @satyam2312 Před rokem +1

    it won't work for duplicate as well as for negative.

  • @abhinavvgoyall
    @abhinavvgoyall Před rokem

    Very helpful videos!

  • @Ajay51702
    @Ajay51702 Před rokem

    hello, i am complete BCA in 2014 now i want to job for java background but i am late does it's possible to gets jobs..please reply me....

  • @upendrakumarjha9245
    @upendrakumarjha9245 Před 9 měsíci

    Wahh bhaia mjaa aagya🎉

    • @HelloWorldbyprince
      @HelloWorldbyprince  Před 8 měsíci

      Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀

  • @vanivaishnavi3916
    @vanivaishnavi3916 Před rokem

    happy birthdayyyyyyyyy to you❣❣

  • @divasbhadani9225
    @divasbhadani9225 Před 4 měsíci

    Amazing concept 🤩
    Minor fix required for duplicate items ( [2,3,1,1] ) its returns wrong answer, so fix is that
    if(idx < n && nums[idx] > 0) {
    nums[idx] *= -1;
    }

  • @nikitajain6214
    @nikitajain6214 Před 9 měsíci

    test case wrong aayenge first sort the array sort(arr,arr+n); then iterate

  • @amitprasadiitg2564
    @amitprasadiitg2564 Před rokem +1

    nums =[1,1]. for this case it will fail.....

  • @adityaaman2448
    @adityaaman2448 Před rokem

    bhaiya it will fail for [1,1]

    • @rutwikmore7462
      @rutwikmore7462 Před rokem

      class Solution {
      public:

      int firstMissingPositive(vector& nums) {
      for(int i = 0;i < nums.size(); i++){
      if(nums[i] 0){
      nums[index]*=-1;
      }
      }
      for(int i = 0;i < nums.size();i++){
      if(nums[i] > 0){
      return i+1;
      }
      }
      return nums.size()+1;
      }
      };

  • @akashgoyal8851
    @akashgoyal8851 Před rokem +1

    bhaiya it will fail on test case 1,1

    • @HelloWorldbyprince
      @HelloWorldbyprince  Před rokem

      Why

    • @adityaaman2448
      @adityaaman2448 Před rokem

      @@HelloWorldbyprince check on leetcode plz

    • @JitendraKumar-ud5yc
      @JitendraKumar-ud5yc Před rokem +1

      @@HelloWorldbyprince int firstMissingPositive(vector& nums) {
      for(int i=0;i

    • @JitendraKumar-ud5yc
      @JitendraKumar-ud5yc Před rokem

      int firstMissingPositive(vector& nums) {
      for(int i=0;i

    • @mohitsingwal4116
      @mohitsingwal4116 Před 7 měsíci

      It will fail when any +ve number have even frequency then first one make it negative and second one positive(initial stage). So to solve it just make an extra check arr[index]>0 , only then make it negative(line no 13 in code ). so condition will be index0.

  • @kowshiqkattamuri8977
    @kowshiqkattamuri8977 Před rokem +2

    The following code works fine and passes all the test cases.
    //Approach 2
    //T.C -> O(N), S.C -> O(1)
    //Uses concept of hashing
    int missingNumber_two(int arr[], int n){
    for(int i = 0; i < n; i++){
    if(arr[i] 0){ //arr[index] > 0 to avoid considering the duplicate cases
    arr[index] *= -1;
    }
    }
    //In the below loop, if we find any element greater than 0, then that means (element's index + 1) element is not present in the array
    for(int i = 0; i < n; i++){
    if(arr[i] > 0){
    return i + 1;
    }
    }
    return n + 1; //If all the elements from 1 to n are present, then smallest element that is missing will be n + 1.
    }

  • @paulinashakira536
    @paulinashakira536 Před rokem

    ☹️ 𝐩𝓻Ỗ𝓂Ø𝓈M

  • @aryanmaheshwari1006
    @aryanmaheshwari1006 Před rokem

    playlist ke promotion se jada content pe dhiyan de dete jada like mil jaate or accha bhi lgta.....har video me bas playlist playlist

  • @Viralmems_xyz
    @Viralmems_xyz Před rokem

    bakbass solution

  • @Music-tp8gg
    @Music-tp8gg Před rokem

    Fails for [1,1], Dislike not work in leetcode

    • @JitendraKumar-ud5yc
      @JitendraKumar-ud5yc Před rokem

      int firstMissingPositive(vector& nums) {
      for(int i=0;i

    • @vineetkumar2899
      @vineetkumar2899 Před rokem

      check that value at that indes shloud ne positive then make it negative

  • @devsagar5812
    @devsagar5812 Před rokem

    AC SOLUTION
    int n = nums.size();
    // work on -ve and 0 element
    for(int i = 0; i < n; i++) {
    if(nums[i]

  • @jugalgoswami6083
    @jugalgoswami6083 Před 11 měsíci

    Wrong Solution
    input
    6
    1 1 -2 4 5 2
    Expected output
    3
    your Output
    1