Best Javascript Interview for Freshers| Chakde Frontend Interview EP - 13

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

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

  • @karthikm.1804
    @karthikm.1804 4 หลายเดือนก่อน +12

    in the introduction he said he is proficient in javascript, react, nextjs, typescript and later he said he didn't expect these kind of questions
    Dude, these kind of questions are expected especially when you are with Chirag

  • @karthikm.1804
    @karthikm.1804 4 หลายเดือนก่อน +3

    We can use 2 pointers, i and j. Initially, i will point to arr1[0] and j will point to arr2[0].
    We will then increment the i pointer every iteration, and as soon as the values at index i and j are equal, we will store the value in the result array and increment both the i and j pointers.
    The loop will end when either pointer goes out of bounds.

  • @manishkumarprasad1911
    @manishkumarprasad1911 4 หลายเดือนก่อน +3

    my solution for first question:
    function intersect(arr1, arr2) {
    let arr = [];
    let i = 0;
    let j = 0;
    let n = arr1.length;
    let m = arr2.length;
    while(i < n && j < m ) {
    if(arr1[i] == arr2[j]) {
    arr.push(arr1[i]);
    i++;
    j++;
    } else if(arr1[i] < arr2[j]) {
    i++;
    } else {
    j++;
    }
    }
    return arr;
    }
    console.log(intersect([1, 2, 2, 3, 4, 4], [2,2, 4, 5, 5, 6, 2000]));

  • @bhaviljainnnnnnn
    @bhaviljainnnnnnn 4 หลายเดือนก่อน +4

    I dont think this much hints are provided at interviews, but good questions.

  • @syedazam1611
    @syedazam1611 3 หลายเดือนก่อน +2

    function intersect(arr1, arr2) {
    return arr2.filter((val) => arr1.includes(val) )
    }

  • @srikarravoori124
    @srikarravoori124 4 หลายเดือนก่อน

    I watched it till end. Most of the ReactJs, frontend developer interviews , the first round is completely on the javascript. So, it needs a lot of practice in the initial stage to get command over it. The libraries and frameworks are doesn't matter. Yha, over all the interview is great!

  • @rohitsharma_5064
    @rohitsharma_5064 4 หลายเดือนก่อน +1

    hey chirag bhaiya you are very nice as an interviewer , this isn't we expect our interviewer to that nice

    • @engineerchirag
      @engineerchirag  4 หลายเดือนก่อน +2

      😂😂 interviewers should be nice only 😛

  • @SCRIPTSAG
    @SCRIPTSAG 4 หลายเดือนก่อน +1

    There is three method first one is tow pointer second one is using Hashmap third one is you can use tow loop there is many methods

    • @RajneeshYadav-yl2th
      @RajneeshYadav-yl2th 4 หลายเดือนก่อน

      Yes, absolutely correct but I am talking about the best approach which in more optimized way

  • @AtulKumar-gt7uq
    @AtulKumar-gt7uq 4 หลายเดือนก่อน

    Solutions for 1st question:
    1. Using 2 pointers approach (as we know arrays are sorted)
    2. Using set approach (Useful when array is not sorted)
    Example for 1st approach:
    function intersect(arr1, arr2){
    const resArray = []
    let arr1Index=0, arr2Index=0;
    while(arr1Index

  • @shubhamthaker9380
    @shubhamthaker9380 4 หลายเดือนก่อน +2

    function intersection(arr1, arr2) {
    const result = [];
    for (let i = 0; i < arr1.length; i++) {
    for (let j = 0; j < arr2.length; j++) {
    if (arr1[i] === arr2[j]) {
    if (!result.includes(arr1[i])) {
    result.push(arr1[i]);
    }
    }
    }
    }
    return result;
    }

    • @sankhojjalchatterjee
      @sankhojjalchatterjee 4 หลายเดือนก่อน +1

      This solution isn't correct. This will only give [2,4] as you are using loop inside loop

  • @subhanOther
    @subhanOther 4 หลายเดือนก่อน +2

    function intersect(arr1, arr2) {
    const arr=[];

    arr1.forEach((el,i)=>{

    if(arr2.includes(el)){
    arr.push(el)
    arr2.splice(arr2.indexOf(el),1)
    }
    })

    return arr
    }
    const result = intersect([1, 2, 2,3, 4, 4], [2,2, 4, 5, 5, 6, 2000])
    console.log(result);

    • @Jagddis
      @Jagddis 4 หลายเดือนก่อน

      simple and easy

  • @puneetuttam6476
    @puneetuttam6476 4 หลายเดือนก่อน +2

    ar1 = [1, 2, 2, 3, 4, 4];
    ar2 = [2, 2, 4, 5, 6, 200];
    // output: 2 2 4
    ans = [];
    let i = 0;
    let j = 0;
    while (i < ar1.length && j < ar2.length) {
    if (ar1[i] === ar2[j]) {
    ans.push(ar1[i]);
    i++;
    j++;
    } else {
    if (ar1[i] < ar2[j]) {
    i++;
    } else {
    j++;
    }
    }
    }
    console.log(ans)

  • @artofcoding2010
    @artofcoding2010 4 หลายเดือนก่อน

    Must watch podcast for freshers...the way parth got stuck you can too and this मोदी जी वाला part was epic 😂😅...

  • @letsexplore2093
    @letsexplore2093 4 หลายเดือนก่อน

    if anyone want find this all this quetions, where can we can get it?

  • @87subhamoy.r
    @87subhamoy.r 4 หลายเดือนก่อน

    I have a question arise , all the questions have been asked here , are these questions does we need on regular day to day work?

    • @apoorv15singh
      @apoorv15singh 4 หลายเดือนก่อน

      Yes intersect is probably the thing you would use in day to day code as well and most of the job is about finding bugs in the code, this interview is very close to what you would do as a developer.

  • @yuvrajpardeshi1239
    @yuvrajpardeshi1239 4 หลายเดือนก่อน

    let arr1 = [1,2,2,3,4,4];
    let arr2 = [2,2,4,5,5,6];
    let i=0; let j=0;
    let n1 = arr1.length;
    let n2 = arr2.length;
    let res = [];
    while(i

    • @hello-world556
      @hello-world556 3 หลายเดือนก่อน

      DSA walaa spotted

  • @dilshadazam880
    @dilshadazam880 4 หลายเดือนก่อน

    Here is my solution function intersect(arr1,arr2){
    let j=0;
    let k=0;
    res=[];
    while(j

  • @AtulKumar-gt7uq
    @AtulKumar-gt7uq 4 หลายเดือนก่อน

    Modi Ji ki entry was epic in this video 😅

  • @openworld7585
    @openworld7585 3 หลายเดือนก่อน

    function intersect(arr1,arr2) {
    let obj1 = {}
    let obj2 = {}
    let resultArray = []
    for(let i = 0;i

  • @pratik5115
    @pratik5115 4 หลายเดือนก่อน +5

    Bechara Fresher

  • @negativegaming2110
    @negativegaming2110 4 หลายเดือนก่อน

    function intersect(arr1,arr2){
    const resArr = [];
    const tempArr = arr2;
    for(let i=0; i

  • @_sayantan_
    @_sayantan_ 3 หลายเดือนก่อน

    function intersect(arr1, arr2){
    const intArr = []
    let i = 0;
    let j = 0;
    while(arr1[i] && arr2[j]) {
    if(arr1[i]==arr2[j]){
    intArr.push(arr1[i])
    i++;
    j++
    } else if(arr1[i]

  • @omnikingomniking6412
    @omnikingomniking6412 4 หลายเดือนก่อน +1

    Clearly rejected

  • @DebayanMukherjee-wo2ul
    @DebayanMukherjee-wo2ul 4 หลายเดือนก่อน

    In Mahabharat karna's wheel was stuck......here parth is got stuck 😂

  • @sankhojjalchatterjee
    @sankhojjalchatterjee 4 หลายเดือนก่อน

    My solution:
    const intersect = (arr1, arr2) => {
    const result = [];
    for(let i = 0; i< arr1.length; i++){
    if(arr2.includes(arr1[i])){
    result.push(arr1[i]);
    //remove the item from the second arr
    const index = arr2.findIndex(item => item === arr1[i]);
    arr2.splice(index,1)
    }
    }
    return result
    }

    • @RajneeshYadav-yl2th
      @RajneeshYadav-yl2th 4 หลายเดือนก่อน +1

      It's not an optimize way, you can also use
      let idx = arr2.indexOf(arr[i]
      if( idx !== -1 ){
      result.push(arr[i]);
      arr2[idx]=""
      }
      return result
      but it's better than you but it's also not optimize way, You have to use two pointer technic for optimization