JavaScript LIVE Coding Interview Round (Mock)

preview_player
Показать описание
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)

🧑‍🏫 Full Course Playlists

💻 Projects Playlists

🕹 Mini Projects (Single Video)

Рекомендации по теме
Комментарии
Автор

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);

rajatraj
Автор

Please keep making such videos like these

pritamkeshri
Автор

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);

Rohit-zskn
Автор

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

goldybhardwaj
Автор

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)

coderelevel
Автор

const input = [2, 7, 11, 4, -2]
let arr=[0, 0, 0, 0, 0];
arr[0] = input[0];
for(let i=1; i<input.length; i++){
arr[i]=arr[i-1]+input[i];
}
const totalSum = input.reduce((acc, curr)=>{
return acc+curr;
}, 0)
for(let i=0; i<input.length; i++){
arr[i]=totalSum-input[i];
}
console.log(totalSum)
console.log(arr) Professional approach

ohiogozaimasu
Автор

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);

Its_Abhi_Thakur
Автор

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

ishwarmore
Автор

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);

chaybislam
Автор

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

monnuvibes
Автор

let netsum = inputSum.reduce((acc, curr)=>{
return acc+curr;
}, 0);

let output = inputSum.map((val, index, arr)=>{
return netsum-val;
});

console.log(output);

skyhi
Автор

Add more interview machine coding rounds. Good content 👍

merajali
Автор

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

mvnsccj
Автор

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

harshkashyap
Автор

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.

sushantsaud
Автор

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){

}
console.log(resArr);

jaspreetsingh-
Автор

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);

devjariwala.j
Автор

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 ?

sudhansusekhar
Автор

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

akashkadukar
Автор

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

manimaran