Javascript LIVE Coding Interview (Mock) #javascript #reactjs

preview_player
Показать описание
We had an interview with Raghbir Singh who is a Non-CS student. He is preparing for coding interviews at various companies. We took this interview Live via Zoom call.

🤯 Crash Courses (Single Video)

🧑‍🏫 Full Course Playlists

💻 Projects Playlists

🕹 Mini Projects (Single Video)

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



JavaScript Interview Shorts:

React Interview Shorts :



REACT Interview Shorts :

JAVASCRIPT Interview Shorts:


coderdost
Автор

const input1 = { a: 1, b: 2, c: 3, d: 10, e: 12 };
const input2 = { a: 2, e: 12, f: 6, d: 10 };

let output = {};
=> {
if (input2[item] === input1[item]) {
output[item] = input1[item];
}
});

console.log(output);

shivagyawali
Автор

Abhishek is a very patient and makes the interviewee comfortable. Loved it!

chandanthakur
Автор

Question 3.

const input = [2, 7, 11, 4, -2];
const output = [11, 4, -2, 2, 7];

Solution:

const input = [2, 7, 11, 4, -2];
input.push(input.shift());
input.push(input.shift());
console.log(input);

mitesh_S
Автор

I have discovered your channel just a month ago, and seriously I gain much more confidence on JavaScript then before. Sir You are a great teacher❤❤Your every video really a masterpiece . Thank you so much sir. Please upload content on live small React project.

Currently I am learning React. Paid courses also have no compare to your content, 100% True solid knowledge. "Agar koi aeisa banda bhi aapka video dekh liya ekbar, jisko kuch knowledge hi nhi hai, vo bhi 3 months mei ek front end developer ban sakta hai"

great teacher ! great content ! this channel really deserve Millions of views.

demo
Автор

I am not a js user but I have a logic for Question 3 which is in cpp

int rotate(vector<int>& nums, int k) {
vector<int> temp(nums.size());
for(int i = 0 ; i<nums.size();i++){
temp[(i+k)%nums.size()] = nums[i];
}
return temp;
}
by this u can do it in O(n) and it will put the k under constraints.😁and u can use array too.

bygcxru
Автор

Question-3
const input=[2, 7, 11, 4, -2, ];
const output=[11, 4, -2, 2, 7];


Solution:

function rotateArr(input){
let result=[];
for(let i=2;i<input.length;i++){

result.push(input[i]);
console.log(result)
}
for(let i=0;i<2;i++){

result.push(input[i]);
console.log(result)
}

return result;
}


AdarshMitr
Автор

Sir I am requesting you please make a series on DSA in JavaScript for beginners 🥲 🙏🏼

shahhussain
Автор

to find second largest number :
//asumming there atleast 2 numbers in array

nums=[2, 45, 3, 4, 2, 9, 45]
// initializing max which will keep track of max int and res which will be second largest

let max=nums[0]
let res=nums[1]

if(nums[1]>nums[0]){
max=nums[1]
res=nums[0]
}
//starting loop from the third number coz first two are already assigned;
for(let i=2; i<nums.length ;i++){
if(nums[i]>max){
res=max
max=nums[i]
}
else if(nums[i]>res && nums[i] !=max){
res=nums[i]
}
}
console.log(res)

TIME COMPLEXITY O(N) only traversing through entire array once SPACE O(1)

mysteryman
Автор

let input1 = {a:1, b:2, c:3, d:4}
let input2 = {a:3, b:2, e:4, d:4}

for (const key1 in input1) {
if (key1 in input2 && input1[key1] === input2[key1]) {
console.log(key1, input1[key1]);
}
}

Aman-kbgb
Автор

U can do
Let input=[2, 7, 11, 4, -2]
for(let I =0; I<2;I++){
Input.push(input.shift())
}
consol.log(input)

JAYPATEL-hnnn
Автор

1st question

let input1 = {a:1, b:2, c:4, f:11, t:10}
let input2 = {a:2, b:2, c:3, f:11}

// take out common key with same value {b:2, f:11}
console.log(TakeOutCommon(input1, input2))

***CODE***

function TakeOutCommon(ob1, ob2){
|| {} // if any input object is empty

let ansObject = {}
for(let k in ob1){
if( ( ob1[k] && ob2[k] ) && ob1[k]===ob2[k]){ // checking if both object have same if they have same key then checking for its value
ansObject[k]=ob1[k]
}
}
return ansObject
}

mufadal
Автор

in solution 3 : you can use a recursive reverse array approach to reduce time complexity to O(2n)

rogeramv
Автор

Question 2 : const arr1 = [1, 2, -2, 11, 7, 1];

const findMax = Math.max(...arr1);

const secondLargest = arr1.filter(num => num < findMax)


ashishnirvikar
Автор

Hi sir, this is my solution of finding 2nd largest element;
*Not use of reverse inbuilt function

function find2ndlargest(arr) {
let smax = 0;
let stack = [];
for (let i = 0; i < arr.length; i++) {
while (stack.length !== 0 && stack[stack.length - 1] < arr[i]) {
smax = stack[stack.length - 1];
stack.pop();
}

stack.push(arr[i]);
}
return smax;
}


PHINIxXGaming
Автор

const input1 = {
a: 1,
b: 2,
c: 3,
d: 10,
e: 12,
};

const input2 = {
a: 2,
e: 12,
f: 6,
d: 10,
};

// Function to find common properties with the same values
function findcommonInBoth(obj1, obj2){
const resultingObj = {};

for (const key in obj1) {
if (obj2.hasOwnProperty(key) && obj1[key] === obj2[key]){
//construct a new object
resultingObj[key] = obj1[key]
}
}
return resultingObj
}

const result = findcommonInBoth(input1, input2)
console.log(result);

Shrikant_Jha
Автор

const input = [2, 7, 11, 4, -2]

let spl = input.splice(0, 2)
console.log(spl); //[2, 7]
console.log(input); //[11, 4, -2]

output = input.concat(spl) //1. using concat to merge 2 arrays
// output = [...input, ...spl] //2. using spread operator to merge 2 arrays
// output = input.push(...spl) //3. Merge using array.push()

console.log(output)

//output = [11, 4, -2, 2, 7]

yournanban
Автор

question : 1 ES6 version

const obj1 = {a : 1, b : 2, c : 3, d: 4, e : 5}
const obj2 = {e : 4, c : 3, r : 6, a:1, f : 9, p : 4}
const keys1 = Object.keys(obj1)
const keys2 = Object.keys(obj2)
const resultObject = {}

const commonKeyCollector = keys1 > keys2 ? keys2.filter((key2) => keys1.includes(key2)) : keys1.filter((key1) => keys2.includes(key1))

commonKeyCollector.map((key) => {
if(obj1[key] === obj2[key]){
resultObject[key] = obj1[key]
}})

console.log(resultObject)

rushabhdave
Автор

function secondLargest(input1){
input1.sort((a, b)=>b-a);
for(let i=0;i<input1.length-1;i++){
if(input1[i]==input[i+1]){
continue;
}
else{
return input1[i];
}
}}
const input=[1, 2, 11, 22, 33, 44, 22, 33, 44]

inspireVoyage
Автор

const value_1 = [1, 2, -2, 11, 7, 1]; // output 7
const value_2 = [1, 4, 7, 2, 4, 7]; // output 4

function nextBiggest(arr) {
let max = 0,
result = 0;

for (const value of arr) {
if (value > max) {

result = max;
max = value;

} else if (value < max && value > result) {
result = value;
}
}

return result;
}

akash_gupta_