Shift All Zero Elements to Right Side of the Array - Java interview Question

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 พ.ย. 2024

ความคิดเห็น • 28

  • @rajatnegi3408
    @rajatnegi3408 3 ปีที่แล้ว +1

    Naveen Sir, I was asked this question recently. I was searching the logic but saw this video.. Thanks for helping people in the testing community.. you are a true blessing for us.. Thank you

  • @SceneSn1ppets
    @SceneSn1ppets 3 ปีที่แล้ว +5

    Just 2 days back I was asked the same question in one of the top MNCs, I did it through arraylist using .add and . remove in one loop

  • @MrPankajchakraborty
    @MrPankajchakraborty 3 ปีที่แล้ว +1

    Thanks Naveen, gone through all 40 videos and with most of them learnt something new. Really appreciate your efforts. please keep going and keep growing 👍

  • @sanketh768
    @sanketh768 3 ปีที่แล้ว +1

    Thank you Naveen. Please continue to do these kinds of coding problems

  • @meghaagarwal7721
    @meghaagarwal7721 3 ปีที่แล้ว +2

    This series is really really helpful 👍

  • @chetanurkudkar
    @chetanurkudkar 2 ปีที่แล้ว

    Thanks a lot sir. This trick is very helpful, its very handy in many other array operations too.

  • @amanjotkaur774
    @amanjotkaur774 3 ปีที่แล้ว +1

    Really appreciate your efforts sir 👍 thanks 😊

  • @soumyajit443
    @soumyajit443 3 ปีที่แล้ว

    Hi Naveen,
    I was asked this question "how to Shift All Zero Element to Left Side of the Array" in my last interview. Can you please make a video of the same?

  • @sagarshrivastava2325
    @sagarshrivastava2325 3 ปีที่แล้ว

    Hi Naveen...which tool/device/pad you are using to explain using pen (seems very smooth)...can you please share the details ?

  • @gopichinthagumpula6481
    @gopichinthagumpula6481 3 ปีที่แล้ว

    Brother keep Doing... It's really helping

  • @gowthamrockz
    @gowthamrockz 3 ปีที่แล้ว +1

    Thank you, Naveen.

  • @anjaliupadhayay9076
    @anjaliupadhayay9076 3 ปีที่แล้ว +1

    Thank you so much sir

  • @subramanianr2744
    @subramanianr2744 3 ปีที่แล้ว +6

    Logic for shift left:
    int count = 0;
    for (int num : a) {
    if(num == 0) {
    newArray[count]=num;
    count++;
    }
    }
    for(int num : a) {
    if(num !=0) {
    newArray[count]=num;
    count++;
    }
    }

  • @shankumondal2881
    @shankumondal2881 3 ปีที่แล้ว

    Naveen , what FONT do you use in eclipse ?

  • @storyteller_x
    @storyteller_x 3 ปีที่แล้ว

    Hey naveen,
    Can you do a program regarding setting the custom date and time and getting the date & Time.
    Take a custom class and set the date and get the salary details according to the year of joining.
    #interviewquestion

  • @prakashbtw678
    @prakashbtw678 3 ปีที่แล้ว

    Please suggest any material to learn solve problems in leet code, hackerrank...

  • @appansingharoy491
    @appansingharoy491 3 ปีที่แล้ว

    Java is fun❤️

  • @prakashbtw678
    @prakashbtw678 3 ปีที่แล้ว +1

    Thank you

  • @rohitsoni2598
    @rohitsoni2598 3 ปีที่แล้ว +1

    Sir 1 hi dil h kitni baar jeetoge.

  • @soumyajit443
    @soumyajit443 ปีที่แล้ว

    Please share the program for keeping all zeros to the left hand side of the array . This is being asked in interviews

  • @vidyabathija9112
    @vidyabathija9112 3 ปีที่แล้ว

    Thank You.

  • @kishorekumar3620
    @kishorekumar3620 3 ปีที่แล้ว

    Hii Naveen ,can you please tell the logic for shift left without out using two new arrays

    • @subramanianr2744
      @subramanianr2744 3 ปีที่แล้ว

      int count = 0;
      for (int num : a) {
      if(num == 0) {
      newArray[count]=num;
      count++;
      }
      }
      for(int num : a) {
      if(num !=0) {
      newArray[count]=num;
      count++;
      }
      }

    • @rohitsoni2598
      @rohitsoni2598 3 ปีที่แล้ว +1

      @@subramanianr2744 one correction
      subu subramani
      3 hours ago
      int count = 0;
      for (int num : a) {
      if(num == 0) {
      newArray[count]=num;
      count++;
      }
      }
      you don't need to write newAray[count]=num; bcoz newArray by default is taking 0. Hope it help u

  • @healthbeautytips6438
    @healthbeautytips6438 3 ปีที่แล้ว

    What will be the time complexity of this programme as we are creating a new array here. Can we achieve it by single array only.

    • @naveenautomationlabs
      @naveenautomationlabs  3 ปีที่แล้ว +1

      It will be O(n) only but with extra space. As I am not manipulating the existing array.

    • @healthbeautytips6438
      @healthbeautytips6438 3 ปีที่แล้ว

      @@naveenautomationlabs thanks Naveen

  • @pandudamera7211
    @pandudamera7211 3 ปีที่แล้ว

    Thank you brother