JavaScript LIVE Coding Interview Round (Mock)

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024
  • In this video, we have a candidate, who tries to solve a live coding problem in a javascript interview.
    #reactjs #javascript #interview #leetcode
    🤯 Crash Courses (Single Video)
    Git/Github Crash Course : bit.ly/3JSA5VT
    TypeScript Crash Course : bit.ly/372dZSh
    Angular Crash Course : bit.ly/3DoGJR1
    Vue JS Crash Course : bit.ly/3uDujRl
    Python Crash Course : bit.ly/3Dod7U2
    React Router Crash Course : bit.ly/36YfO2i
    🧑‍🏫 Full Course Playlists
    HTML : bit.ly/36IMq0h
    CSS : bit.ly/3LpRQw6
    JavaScript : bit.ly/3u049tf
    BootStrap : bit.ly/3NA9nDJ
    ES 6 : bit.ly/3DvYCh6
    DOM Playlist : bit.ly/35nMKB7
    ReactJS (Redux & Hooks) : bit.ly/3iMethN
    React with TypeScript : bit.ly/3fQjXtF
    React Hooks: bit.ly/3Vmh7wV
    Redux: bit.ly/3yAIIkl
    NodeJS/ExpressJS : bit.ly/35nN6Yt
    MongoDB / Mongoose : bit.ly/3qPj0EO
    💻 Projects Playlists
    MERN Stack Complete Ecommerce : bit.ly/3ymSs0E
    Web Design HTML+CSS - Home Page : bit.ly/35nZiIB
    Web Design BootStrap - E-Commerce Site : bit.ly/3iPhaz7
    React/Redux/Firebase - Todo-App : bit.ly/3DnekL8
    🕹 Mini Projects (Single Video)
    React - Tic Tac Toe (Redux / Hooks) : bit.ly/3uzLEuy
    React - Game of Flag Quiz (Hooks) : bit.ly/3LpTC0e
    React - Google Translate Clone (Hooks) : bit.ly/3Lo9xvZ
    React - Chat App using Firebase (Hooks) : bit.ly/3wLgymj
    Visit our site: coderdost.com
    🔴 Full Courses List : coderdost.com/...
    🔴 Full Projects List : coderdost.com/...
    💾 Source Codes at : github.com/cod...

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

  • @rajatraj3160
    @rajatraj3160 Год назад +22

    const input =[2,7,11,4,-2]
    let output = [20,15,11,18,24]
    let sum = input.reduce((a,b)=>a+b)
    let totalsum = []
    for (const value of input) {
    totalsum.push(sum-value)
    }
    console.log(totalsum);

  • @Its_Abhi_Thakur
    @Its_Abhi_Thakur Год назад +8

    let arr = [2, 7, 11, 4, -2];
    let output = [];
    for (let i = 0; i < arr.length; i++) {
    let sum = 0;
    for (let j = 0; j < arr.length; j++) {
    if (j == i) {
    continue;
    } else {
    sum += arr[j];
    }
    }
    output.push(sum);
    }
    console.log(output);

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

      let input = [2,7,11,4,-2];
      let sum = 0;
      for(let ele of input)
      sum+=ele;
      let output = new Array();
      for(let x of input)
      {
      let z = sum - x;
      output.push(z);
      }
      console.log(output);
      O(n) Time

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

      This is o(n2) time complexity. This can be done in o(2n)==o(n)

  • @coderelevel
    @coderelevel Год назад +6

    I have just tried to make the code more Efficient, hope it helps :
    const sum = input.reduce((a,b) => {
    return (a+b)
    })
    const result = input.map(item => sum-item)
    console.log(result)

  • @Rohit-zs7kn
    @Rohit-zs7kn Год назад +4

    const input = [2, 7, 11, 4, -2];
    const sum = input.reduce((a, b) => a + b, 0);
    const output = input.map((e) => sum - e);
    console.log(output);

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

    const input = [2,7,11,4,-2];
    const output = [];
    for(let i=0; i

    • @navinkumarsahu1159
      @navinkumarsahu1159 10 месяцев назад +1

      just compare u===i not input[u] === input[i] as this will skip the addition of same number

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

    Please give some question everyday ! This helps me to build my confidence ! Believe me solve karne ke bad hi puri video dekhta hu ! Mene kiss approche se kia or sammne kaise kr raha hai

  • @supplymeweed
    @supplymeweed Месяц назад

    const input = [2,7,11,4,-2]
    let arr=[0,0,0,0,0];
    arr[0] = input[0];
    for(let i=1; i{
    return acc+curr;
    },0)
    for(let i=0; i

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

    3 line code including console.log and input
    const arr = [2,7,11,4,-2];
    const sum = arr.reduce((a,b) => a+b);
    console.log( arr.map( I => sum-i ));
    Not that complicated straight forward logic

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

    const input = [2, 7, 11, 4, -2];
    const output = [];
    for (let i = 0; i < input.length; i++) {
    let sum = 0;
    for (let j = 0; j < input.length; j++) {
    if (j === i) continue;
    sum += input[j];
    }
    output.push(sum);
    }
    console.log(output);

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

      But time complexity may be O(n^2) ,
      We can write two loop diff first for finding sum and then for the sum - input [i]

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

    let netsum = inputSum.reduce((acc,curr)=>{
    return acc+curr;
    },0);
    let output = inputSum.map((val,index,arr)=>{
    return netsum-val;
    });
    console.log(output);

  • @jaspreetsingh-5259
    @jaspreetsingh-5259 Год назад +1

    const input=[2,7,11,4,-2];
    const output=[20,15,11,18,24]
    const sum=0;
    newArr=input.map((item)=>input.reduce((acc,i)=>acc+i,sum));
    let resArr=[];
    for (let i in input){
    resArr.push(newArr[i]-input[i])
    }
    console.log(resArr);

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

    let arr = [2,7,11,4,-2]
    let total = 0
    let totalArr = []
    for(let i=0; i

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

    I think this is enough!!
    console.log(input.map(num => input.reduce((sum, num) => sum + num) - num))
    edited: it's better to use reduce only once and save the value for later, instead of calculating for every map element
    let sum = input.reduce((sum, num) => sum + num)
    console.log(input.map(num => sum - num))

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

      It's time complexity is way too much as reduce function will run n times. N2 time complexity.

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

      @@khageshbansal2400 sir! Please read the full comment..xD

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

      @@OctTEN_1010 well played 👏

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

    const arr = [2, 7, 11, 4, -2];
    let sum = 0;
    let newArr = []
    function output() {
    for (let i = 0; i < arr.length; i++) {
    sum += arr[i]
    }
    const value = sum;
    console.log(value);
    for (let i = 0; i < arr.length; i++) {
    let num = value - arr[i];
    console.log(num);
    newArr.push(num)
    }
    return newArr
    }
    const a = output();
    console.log(a);

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

    let a = [2, 7, 11, 4, -2];
    let out = [20, 15, 11, 18, 24];
    let b = [];
    for (let i = 0; i < a.length; i++) {
    b.push(
    a.reduce((a, b) => {
    return a + b;
    }, 0) - a[i]
    );
    }
    console.log(b);

  • @devjariwala.j
    @devjariwala.j 11 месяцев назад

    Simplest code just tooked me 10mins to solve, this guy is hilarious 🤣🤣😂😂
    const input = [2, 7, 11, 4, -2];
    const output = input.map((el, i, arr) => {
    const sumableElms = arr.map((elm, ind) => {
    return i === ind ? 0 : elm;
    });
    let sum = 0;
    sumableElms.map((elm) => {
    return (sum += elm);
    });
    return sum;
    });
    console.log("Output : ", output);

  • @AkashSingh-xf6bd
    @AkashSingh-xf6bd Год назад

    @Coder Dost i think this is full fill the requirement
    let arr =[2,3,4,5]
    function sn(arr){
    let result = [];
    for(let i =0;i< arr.length;i++){
    let sum = 0;
    for(j=0;j< arr.length;j++){
    if(i===j){
    continue;}
    else{
    let temp = arr[j];
    sum += temp
    }
    }
    result.push(sum)
    }
    return result
    }
    console.log(sn(arr))
    Thanks
    ++++++++++++++++++++++++++++++++++++++
    let arr =[2,3,4,5]
    function sn(arr){
    let result = [];
    for(let i =0;i< arr.length;i++){
    let sum = 0;
    for(j=0;j< arr.length;j++){
    let temp = arr[j];
    sum += temp
    }
    sum -= arr[i]
    result.push(sum)
    }
    return result
    }
    console.log(sn(arr))

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

    const input = [2, 7, 11, 4, -2]
    let sum = input.reduce((a, b)=>a+b)
    for(let i =0; i sum -item)
    }
    console.log(output)

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

    let arr = [2, 7, 11, 4, -2];
    let arr1 = [];
    const result = arr.reduce((pre, curr) => {
    return pre + curr;
    },0);
    for(let val of arr){
    let itemval=result-val;
    arr1.push(itemval);
    }
    console.log(arr1);
    This work for me.

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

    input=[2,7,11,4,-2];
    output=[ ];
    let sum = input.reduce((acc,cur)=>acc+cur);
    for(let i=0;i

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

    const number = [2, 7, 11, 4, -2];
    const array = []
    for(let i=0; i acc + cur);
    array.push(total - number[i]);
    }

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

    Too simple.
    Step 1. Calculate sum of the whole array. In case [2,7,11,4,-2].
    Sum is = 22.
    Step 2: Map through the input array and subtract the each element on by by with the Sum.
    Example:
    let output = input.map((value)=>{
    return (Sum - value)})
    output [20,15,11,24]
    Time complexity O(n)
    Auxilary space O(n) =>output array

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

    Please keep making such videos like these

  • @user-mv7ns1cc3j
    @user-mv7ns1cc3j Год назад

    const input=[2,5,6,9,4,-2];
    let output=[];
    for(var i=0;ival+acc)
    output.push(out-input[i]);
    }
    console.log(output);

  • @Santoshkumar-bb2oq
    @Santoshkumar-bb2oq 9 месяцев назад

    const input = [2,7,11,4,-2]
    const sum = input.reduce((total, curr) => total + curr)
    const output = input.map(num => sum - num)
    console.log(output)

  • @ShuvamSaini
    @ShuvamSaini 9 месяцев назад

    function func(input) {
    const newArray = [];
    const sum = input.reduce((acc, cur) => {
    return acc + cur;
    }, 0);
    for (let i = 0; i < input.length; i++) {
    const item = sum - input[i];
    newArray.push(item);
    }
    return newArray;
    }
    const input = [2, 7, 11, 4, -2];
    const output = func(input);
    console.log(output);

  • @merajali938
    @merajali938 7 месяцев назад

    Add more interview machine coding rounds. Good content 👍

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

    Hello sir , i have a question
    If i am going to give interview for javascript
    If he/she ask me DSA
    So, can i do the DSA problem in c++ language ?

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

      generally they ask only the psuedo code or white board logic and implementation. but if they ask to implement code. any well-konwn language is generally accepted - C++. Java. Python or JavaScript.

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

    const input = [2, 7, 11, 4, -2]
    const output = [20, 15, 11, 18, 24]
    let sum = 0;
    let result = []
    let currIndex = 0
    for (let i=0; i {
    if(input.indexOf(num) !== i){
    return num
    }
    }).reduce((acc, curr) => {
    acc = acc + curr;
    return acc
    }, 0)
    result.push(sum)

    }
    console.log(result);

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

    const input = [2,7,11,4,-2];
    //const output = [20,15,11,18,24];
    function sumOfAll(arr){
    const output = [];
    for(let i = 0;i index !== i).reduce((acc,cur)=>acc+cur,0);
    output.push(tempOutput);
    }
    return output;
    }
    console.log(sumOfAll(input));

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

    I have solved this from just after know the question didn't watch the full length of the video but once I dragged the video in last Sir suggested the same what I done here

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

    Very Helpful 😊

  • @rapper3470
    @rapper3470 10 месяцев назад

    let arr = [2,7,11,4,-2]
    let ans =[];
    let sum = arr.reduce((a,b)=>a+b,0);
    arr.forEach((elm)=>{
    ans.push(sum-elm);
    })
    console.log(ans);

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

    // the most basic way to do without map and reduce
    let arr = [2,7,11,4,-2];
    let sumArr = [];
    for(let i=0;i

  • @srinilm3010
    @srinilm3010 28 дней назад

    function CheckArr(arr) {
    // Method 1
    let res1 = [];
    for (let i = 0; i < arr.length; i++) {
    let left = arr.slice(0, i);
    let right = arr.slice(i + 1, arr.length);
    let temp = [...left, ...right].reduce((a, b) => a + b, 0);
    res1.push(temp);
    }
    // Method 2
    let res = []
    for (let i = 0; i < arr.length; i++) {
    let temp = 0
    for (let j = 0; j < arr.length; j++) {
    if (i !== j) {
    temp += arr[j]
    }
    }
    res.push(temp)
    temp = 0
    }
    console.log(res1);
    console.log(res);
    }
    let arr = [2, 7, 11, 4, -2];
    console.log(CheckArr(arr));
    // [ 20, 15, 11, 18, 24 ]

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

    Let arr=[2,7,11,4,-2]
    Let sum=arr.reduce(
    (tatal,num)=>{
    return tatal+num
    },0)
    Let new_arr=[];
    for(let i = 0; i

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

      Superb👌

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

      let nums = [2, 7, 11, 4, - 2]; let total = nums.reduce((a, b) => a + b);
      let sums = nums.map(num => total - num);
      console.log(sums);
      How it to be solved with map 🤔

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

      @@Factvideo014 👏👏

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

    // sum of all elements except that index element
    function arrayOfSum(ar){
    let sum=ar.reduce((acc,ele)=>acc+ele);
    let finalAr=[];
    ar.map(ele=>{
    finalAr.push(sum-ele);
    })
    return finalAr;
    }
    arrayOfSum([2,7,11,4,-2]);

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

    1st :
    const code = (arr)=> {
    return arr.map((el, ind) => {
    let sum = 0
    arr.forEach((item, index) => {
    if(ind !== index){
    sum+=item
    }
    })
    return sum
    })
    }

  • @SaurabhSingh-wg1pm
    @SaurabhSingh-wg1pm 28 дней назад

    const input = [2, 7, 11, 4, -2];
    function sum(){
    let sum;
    const SUMS = [];
    for(let i=0; i

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

    const data = [2, 7, 11, 4, -2]
    const outputArr = []
    for(let i =0; i < data.length; i ++ ) {
    let sum = 0;
    for(let j =0; j < data.length; j ++) {
    if( data[i] !== data[j]){
    sum = sum + data[j]
    }
    }
    outputArr.push(sum)
    }
    console.log(outputArr)

  • @MrAmitbarthwal
    @MrAmitbarthwal 6 месяцев назад

    const A = [2,7,11,4,-2];
    const newArr = [];
    function fun(array){
    for (let index = 0; index < array.length; index++) {
    let sum = 0;
    array.forEach((e,i) => {
    if(index != i) {
    sum = sum + e;
    }
    });
    newArr.push(sum)
    }
    console.log(newArr);
    }
    fun(A)

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

    his solution
    let arr = [2,7,11,4,-2];
    let resArr = [...arr];
    resArr.reverse();
    let left = [0];
    let right = [0];
    let output = [];
    for(let i = 1 ; i< arr.length;i++){
    left[i] = left[i-1] + arr[i-1];
    right[i] = right[i-1] + resArr[i-1];
    }
    for(let i = 0 ; i < arr.length;i++){
    output.push(left[i]+right[arr.length-1-i])
    }
    console.log(output)

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

    My answer for Sum 1:
    var arr1 = [2,7,11,4,-2];
    var sum = arr1.reduce((first,second) => {
    return first+second;
    });
    var newArray = [];
    for(let i of arr1){
    var NewOne = sum - i;
    newArray.push(NewOne);
    }
    console.log(newArray);

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

    let totalSum=0;
    arr.forEach((value)=>{
    totalSum+=value
    })
    const result=arr.map((value)=>{
    return totalSum-value
    })
    console.log(result)

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

    Easiest way 😉
    const arr = [2,7,11,4,-2];
    let newArr = []
    arr.indexOf(5);
    arr.forEach((num,i) =>{
    let sum = 0;
    arr.forEach(n =>
    if(n !== num){
    sum+=n
    });
    newArr[i] = sum;
    });
    console.log(newArr)

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

    function sumof(input){
    let output=[]
    let sum=0
    for(let i=0;i

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

    //without nested for loop for begineer
    let input = [2,7,11,4,-2];
    let output = []
    let sum = 0
    for(i in input){
    sum += input[i];
    }
    for(i in input){
    output.push(sum - input[i])
    }
    console.log(output)

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

      I think without nested loop is better solution most of times. As code becomes less complex

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

    everyone in comments just posting copied code from chat gpt instead of apprecating the guy who has a most different approch to solve the problem even though it was very comples but still i was there sitting i would simply have quited

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

    const input = [2, 7, 11, 4, -2];
    let output = [];
    input.forEach(element => {
    let sum = 0;
    input.forEach(allElement => {
    if(element !== allElement) {
    sum += allElement;
    }
    });
    output.push(sum);
    });
    console.log(output); // [20, 15, 11, 18, 24];

  • @animeloverz.online
    @animeloverz.online Год назад

    let a=[2,4,11,23,-3];
    let sum=0;
    let b =[];
    let n=0;
    while(n!=5){
    for(let i=0;i

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

    const result=[]
    for(let i=0;i

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

      You can improve this solution, without using nested for loops.

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

    const arr = [2,7,11,4,-2];
    const result = arr.map((v) => arr.reduce((pv, cv) => pv += cv, 0) - v);
    console.log(result); // [20,15,11,18,24]

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

      Shortness wise good. but you can catch that REDUCE code will be running un-necessary many times here.

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

      Time complexity = O(n^2)
      You can first calculate the sum of all numbers. Then use for-loop and minus from each number. You'll get O(2n) ~ O(n)

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

    How to contact you man your questions are related to very deep understanding

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

      Mail address is in about section. Also for session we launch a form evry now and then on community posts

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

    Bhai yeh bhi mention kr diya kro ki yeh freshers hai ya experience.

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

      most interviews are fresher

  • @ezegilsc
    @ezegilsc 6 месяцев назад

    Filter , reduce use kro 10 line ka cide hai

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

    Let input=[4,7,3,9]
    Input.reduce((sum,cur)=>sum+cur)
    Let output = input.map((cur)=>sum-cur);

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

      Logic seems right. But variables kuch kam nhi hogye..

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

      @@coderdost let input=[4,7,3,9]
      let sum = input.reduce((sum,cur)=>sum+cur);
      let output = input.map((cur)=>sum-cur);
      console.log(output);

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

    Dost! I wonder how you select these candidates to interview. Are they are your subscribers, or ......

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

      anyone can apply. I publish FORM regularly. next form will come in 1-2 days. on community post

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

      form is available now

  • @Bhaskar073
    @Bhaskar073 7 месяцев назад

    bro js interview coding vedios cheyyandi bro

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

    const input = [2, 7, 11, 4, -2];
    let count = [];
    for (let i = 0; i < input.length; i++) {
    let sum = 0;
    for (let j = 0; j < input.length; j++) {
    if (i != j) {
    sum = sum + input[j]
    }
    }
    count.push(sum)
    }
    console.log("Sum Of Element of an array ", count)

  • @harshalsuryawanshi946
    @harshalsuryawanshi946 7 месяцев назад

    //Given Input Arr
    const inputArr = [2, 7, 11, 4, -2];
    //New Empty Array
    const newArr = [];
    //
    const sumArr = (inputArr) => {
    inputArr.forEach((num) => {
    const filterArr = inputArr
    .filter((el) => el != num) //will remove current elemnt from array
    .reduce((acc, current) => {
    // taking sum of remaining
    return acc + current;
    }, 0); // final return will be sum value
    newArr.push(filterArr); //Inserting element into new array
    });
    return newArr;
    };
    //
    console.log(sumArr(inputArr)); // [ 20, 15, 11, 18, 24 ]
    console.log(inputArr); // [ 2, 7, 11, 4, -2 ]

  • @NitinSingh-ug5ny
    @NitinSingh-ug5ny Год назад

    let input = [2,7,11,4,-2]
    let output=[20,15,11,18,24]
    let newArr = []
    let element;
    for(let i =0;i

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

      Sum is getting calculated many times. You can try with non nested loop also

    • @NitinSingh-ug5ny
      @NitinSingh-ug5ny Год назад

      @@coderdost
      let arr =[2,7,11,4,-2]
      let n = arr.length;
      let sum =0;
      for(let i =0;i

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

      @@NitinSingh-ug5ny good enough

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

      @@coderdost sir here he declared "element" using LET and after then he assigning value inside FOR loop....but let have block scope

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

      @@NitinSingh-ug5ny ..?

  • @ganeshks9344
    @ganeshks9344 5 месяцев назад

    let arr=[2,7,11,4,-2]
    let newArr=[];
    for(let i=0;i

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

    Hi sir , Please check my approach with using a pointer at time O(n2) [edited]
    let ans = [];
    for(let i=0;i

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

      But this is not O(n). while loop always starting from 0 and going to N - so it will beO(n2)

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

      @@coderdost Yes sir You are right sir , its my mistake ,can is any way we can solve this in order of n ?

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

      @@PHINIxXGaming The trick here is that : (SUM of ARRAY - Current element) will give us the solution. so its O(n)

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

    Why he is making this simple question so complicated?

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

      Pressure of interview , makes it difficult

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

      @@coderdost real truth... Also happen with me

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

    This types guys are there in big MNC companies 🤣🤣
    There are just talking too much but coding knowledge is nothing

    • @devjariwala.j
      @devjariwala.j 11 месяцев назад

      Simplest code just tooked me 10mins to solve, this guy is hilarious 🤣🤣😂😂
      const input = [2, 7, 11, 4, -2];
      const output = input.map((el, i, arr) => {
      const sumableElms = arr.map((elm, ind) => {
      return i === ind ? 0 : elm;
      });
      let sum = 0;
      sumableElms.map((elm) => {
      return (sum += elm);
      });
      return sum;
      });
      console.log("Output : ", output);

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

    Easy for Beginners
    thanks me later
    // [2,7,11,4,-2]
    // [20,15,11,18,24]
    let array = [2, 7, 11, 4, -2];
    let answer = [];
    for (let i = array.length-1; i >= 0; i--)
    {
    let temp = 0;
    for (let j = array.length-1; j >= 0; j--)
    {
    if (j === i) {
    continue;
    }
    temp = temp + array[j];
    if (j == 0) {
    answer.unshift(temp)
    }
    }
    if (i == 0)
    {
    temp = 0
    for (let j = 1; j

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

    Sir experience bhi dalo plz ,

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

      This interview was of few months experienced developer

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

      @@coderdost plz upload for experience people as well i.e 2.5-3 years of experience

  • @Zaheer__zk40
    @Zaheer__zk40 8 месяцев назад

    I think bro didn’t got the question

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

    const arr = [1,2,3,4]
    const sum = arr.reduce((a,b)=>{
    return a + b
    })
    const outputArr = arr.map((item, index)=>{
    return sum - arr[index]
    })
    console.log(outputArr)

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

    let sum=0, output=[];
    for(let i=0; i

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

    Hey I want you to take my live coding interview.

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

      You can apply once form is again available. we will post on community post soon.

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

      @@coderdost I will be waiting for it

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

      @@prakashbanjade4374 form is availabe now

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

      @@coderdost OK done

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

      @@prakashbanjade4374 great. check your email tonight or tomorrow for final confirmation

  • @PIYUSH-lz1zq
    @PIYUSH-lz1zq Год назад

    Sir reactjs ka bhi coding round

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

      Frontend coding hard h… ab next rkhenge

    • @PIYUSH-lz1zq
      @PIYUSH-lz1zq Год назад

      @@coderdost if we practice 5-6 coding problems in react also then we would really excel from then !!

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

      @@PIYUSH-lz1zq yes, lets see who is up for this live coding in react challenge. Most people are experts in React concepts and problem solving in JS coding. But many people remain out of touch of really coding in Applications .. like really coding small UI problems and things,..
      We will search for those Heroes 🫡

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

    let arr1 = [2,7,11,4,-2];
    let sum=0;
    for(let i=0;i

  • @yuvraj5283
    @yuvraj5283 8 месяцев назад

    const arr = [2, 7, 11, 4, -2];
    const newArr = [];
    const sumExceptCurrentVal = () => {
    let currentIndex = 0
    let sum = 0;
    while(arr.length - 1 >= currentIndex){
    for(let i = 0; i < arr.length; i++){
    if(currentIndex !== i){
    sum += arr[i]
    }
    }
    newArr.push(sum)
    currentIndex++;
    sum = 0
    }
    return newArr
    }
    console.log(sumExceptCurrentVal()) // [20, 15, 11, 18, 24]

  • @n_fan329
    @n_fan329 9 месяцев назад

    let final=[]
    tab.forEach((val,i)=>{
    final.push( tab.filter(val1=>val1!==val).reduce((a,b)=>a+b,0) )
    })
    console.log(final) // [20,15,11,18,24]