JavaScript interview questions (Count Boomerangs In Array )

Поделиться
HTML-код
  • Опубликовано: 15 авг 2022
  • JavaScript interview questions 🔥 Count Boomerangs In Array #reactinterviewquestions #javascriptinterviewquestions #reactjs #programming #coding
    Please checkout below playlists:-
    1. DAILY ONE REACT INTERVIEW QUESTION
    • Daily React Interview ...
    2. MNC INTERVIEW EXPERIENCES
    • MNC Interview Experiences
    3. TRICKY CSS QUESTIONS/DESIGNS
    • Tricky CSS
    4. MERN PROJECTS FROM SCRATCH
    • MERN Projects
    5. REACT IMPORTANT/RANDOM TOPICS
    • React Topics
    ReactJs Interview
    React/Redux Coding Interview
    Frontend Interview
    javascript interview questions
    reactjs interview questions and answers for experienced
    advanced reactjs interview questions.
    Please subscribe to my channel. Like, share and subscription = 100% MOTIVATION
    I hope you enjoy my channel videos!
    Coffee:- www.buymeacoffee.com/itsCodin...
    Follow On Twitter:- @itscodingdoctor
    Instagram:- / itscodingdoctor

Комментарии • 18

  • @g.pavani5275
    @g.pavani5275 Год назад +1

    Very nice explanation bro it's really awesome ....waiting for regular videos to get uploaded in this interview series of JS

  • @coder0015
    @coder0015 Год назад +3

    Started learning JS recently.
    loved to watch this video, I literally want more of these!!

    • @itscodingdoctor
      @itscodingdoctor  Год назад +1

      Great. You can find 23 more questions in this series

  • @nitinsoni9956
    @nitinsoni9956 Год назад +2

    I love this series but I guess the difficulty level was not hard as it was kind of easy question. I solved the question with the exact solution that was shown in the video.

    • @itscodingdoctor
      @itscodingdoctor  Год назад

      Happy to hear that you could solve it yourself.
      It's a hard question though. But anyone having good knowledge of javascript can solve this.

    • @itscodingdoctor
      @itscodingdoctor  Год назад

      I'll keep on increasing the difficultly level

  • @nittasreenivas4043
    @nittasreenivas4043 Год назад +1

    please solve this question alternating positive and negative number in js input:[9,4,-2,-1,5,0,-5,-3,2] output:[9,-2,4,-1,5,-5,0,-3,2]

    • @itscodingdoctor
      @itscodingdoctor  Год назад

      Sure. Will create a video

    • @nitinsoni9956
      @nitinsoni9956 Год назад +1

      At first the solution seems very simple but when I tried it damn it was tricky. Solved it by first finding indices of negative and positive numbers than using simple loop and finding the lower bounds length and upper bounds of respected arrays assigned the indices to new array and lasted compared which array is bigger and assigned remaining indices from that array.

    • @nitinsoni9956
      @nitinsoni9956 Год назад +1

      let arr = [9, 4, -2, -1, 5, 0, -5, -3, 2,-2,2,3,3];
      // pArr => positive indices nArr=> negative indices
      let pArr = arr.map((el, i) => (el >= 0 ? i : " ")).filter((el) => el !== " ");
      let nArr = arr.map((el, i) => (el < 0 ? i : " ")).filter((el) => el !== " ");
      // to store the new alternate numbers
      let alArr = [];
      // bb & lb => higher bound & lower as one of two arrays can be bigger hence we have to loop till bigger array length
      let bb = pArr.length > nArr.length ? pArr.length : nArr.length;
      let lb = pArr.length < nArr.length ? pArr.length : nArr.length;
      let pi=0,ni=0;
      for (let i = 0; i < bb; i++) {
      // as till lower bound both positive and negative indices array would have same number of elements
      if(lb > i){
      alArr.push(arr[pArr[pi]]);
      alArr.push(arr[nArr[ni]]);
      pi++;ni++;
      }
      else{
      // as positive array is bigger remaing numbers would be added from this array
      if(pArr.length > lb){
      alArr.push(arr[pArr[pi]]);
      pi++;
      }
      // as negative array is bigger remaing numbers would be added from this array
      else{
      alArr.push(arr[nArr[ni]]);
      ni++;
      }
      }
      }
      console.log(alArr);

    • @nittasreenivas4043
      @nittasreenivas4043 Год назад +1

      @@nitinsoni9956 thankyou bro for helping out i just tried like this
      let arr = [9, 4, -2, -1, 5, 0, -5, -3, 2,-2,2,3,3]
      let positive = arr.filter((num) => {
      return num >= 0;
      })
      let negative = arr.filter((num) => {
      return num < 0;
      })
      let result = [];
      for(let i=0,j=0; i

    • @nitinsoni9956
      @nitinsoni9956 Год назад +1

      @@nittasreenivas4043 You're welcome and there was always room for improvement in my code. I'm looking forward how codingDoctor solves the given problem.

  • @sakthiii711
    @sakthiii711 Год назад +1

    Nice video for new topic bro, Please can you make video for [1,2,3,4,5] this will come to X pattern cross method .this was my interview question i don't know how to solve this problem.