I went for a job interview and the manager said, "We're looking for someone who is responsible." "Well I'm your man," I replied. "In my last job, whenever anything went wrong, they said I was responsible."
The anxiety of wanting to tell him his last if statement in fizzbuzz should of been the first was to much for me to handle. Sweet video, love your work.
Yeah, but I liked his solution of concatenating the string. It fits the elements of the problem. DRY, why introduce a 3rd condition when the first two handles it. I also like dividing by 15, I usually break that out into two separate conditions.
your content is the best man. Your javascript tutorials and javascript interview videos helped me get two job offers. Incidentally a question about self invoking functions came up right after i watched the video for it. Keep up the good work, friend!
Please do a small favour for us. While mocking interview, please try to show answer i.e. output in debugger tool or anywhere. It will be very helpful for us. If possible, please do it
Last problem doesn't need the if-else getLastKid = (n, k, i) => (k + i - 2)%n + 1; It could be just (k + i -1)%n but this fails when the kid is the last because mod is 0. So it can also be: last = (k + i -1)%n ; return last == 0 ? n : last ;
Regarding the solution provided by the interviewee for greatest divisor , the solution won't fail but there is an overhead here. Instead of starting from mid of max we should start from mid of min. We are talking about "greatest COMMON divisor". Key is common. Means it should be a divisor of min also along with max. And divisor of min cannot be greater than half of min.
I don't understand why mid is needed in the first place. I have solved it in a function, by checking which parameter is greater and lesser and assigning them to max and min variables respectively. Then checking if they are both positive or one of them is negative with an if statement, If they are both positive I would run them through a for loop counting from MAX down to 1 and in the for loop code block - an IF statement checking if the remainder from dividing max%index && min%index === 0. If so return the index. And if either of the parameters are negative then just reverse the for loop.
Hi TechSith, thank you for all the support by sharing your experience and thoughts. For the question of Creating two adjacent squares with a centered circle problem, I have tried the same in a different way. Can you review it, please? HTML:
Find my solution below for the toys problem: I used i=(i+1)%lengthofarray approach to iterate through a circular array. const a=3; const k=5; var index=0; const c=[]; const d=[]; for(let i=1;i
I would like to suggest the alternative for 2nd css query /***** HTML *****/
/***** css *****/ .parent-square { display: flex; flex-direction: row; } .square { flex: 1; border: 1px solid #000; height: 100px; display: flex; align-items: center; justify-content: center; } .square span { flex-basis: 50px; border-radius: 100%; height: 50px; border: 1px dotted; } Note : as flex feature introduced, you can use flex instead of floats, and to vertically and horizontally center the element, you can use align-items: 'center' or justify-content:'center'' rather then absolute,transform and all those
It's worth noting that `.sq:first-child` is prone to breaking. If you add a div above the , it'll stop selecting. It's trying to select an element that has a class of `sq` AND is the first child of its parent. Also, if you use the same class name elsewhere and it too is a first child of its parent, it'll be selected. To fix it you'd need to raise the specificity on it.
Today I went for an interview and I was able to crack this round. Waiting for final round. Thanks for your videos. Still waiting for your response regarding mock interview
I have a doubt In a web dev interview or react js interview For Ds algo round , can we use java for writing our code instead of js. And for other rounds i will use js. I mean they will provide multiple languages options right in ds algo round ?
The question regarding getting the greatest common divisor between two number could be simplified as follows: function getTheGreatestCommonDivisor(x,y){ let maxPara=Math.max(x,y); let Array=[] for (let i=1;i
function findTheBiggestOne(a, b) { let min = a > b ? b : b; let max = a > b ? a : a; for (let i = max; i > 0; i--) { if (max % i === 0 && min % i === 0) { return i; } } } console.log(findTheBiggestOne(2, 3)); i think this way is more better............
The following solution to kids toys problem worked for all the cases I tried: function lastKidWithToy(k, t, p) { if(pt){ var position = t + p - 1 } else { var position = t%k + p -1 } console.log(position > k ? position-k : position); } else { console.log("Invalid position"); } } lastKidWithToy(7,8,7);
My take on the first function. function fizzy(num){ let str = ''; if(num===0){ return; } if(num>0){ if(num%3==0){ str+='Fizz' } if(num%5==0){ str+='Buzz' } console.log(num+' '+str) return fizzy(num-1); } } fizzy(59);
i have did different approche : let temp = 0; let arr; function distributeToys(n, k, i){ let t = k; if(!t) { temp = 0; return } if(temp < k){ arr = new Int16Array(n); temp = k } for(let index = i; index < n; index++){ if(t == 0) return arr[index] += 1; t-- } distributeToys(n,t,0) } if we did : distributeToys(3, 5, 0) we get : Int16Array(3) [2, 2, 1] this algorithm returns an array of how much each kid get of toys
This series is good.... it would be much better if you can create a series on polyfills. Like how to create all es6 or 7 syntax with es5(example: class, extend etc.). it will help some people to deep dive in prototypes and its uses.
Disclaimer: i paused the video and write my answer First loop through the given range Okay first check if a number is multiple of both 5 and 3 then return fizzbuzz Else if check for multiple of only 3 then return fizz Else if check for multiple of 5 then return buzz Else return the number... You can use in built-in functions as well but above answer is easy to understand when you are a beginner
I have been a developer in Silicon Valley for over 25 years and I have been a lead UI developer and built many products. I have always been 1 of the top front end developers at every company I have worked at. These interview questions are worthless and stupid. They tell you nothing about how good a developer this guy really is. Writing some dumb little function in 5 minutes is not what makes the best developer valuable. The best developers can build a product from the ground up and understand how to design the code for maintainability and make it scale over the years. This interviewer guy in this video must be one of those consulting hacks that build some garbage and then leaves the company onto his next hacking project where he builds garbage that someone else has to clean up. You want to know if someone is a good developer, then look at some source code they have written and see how well it is commented, how well it is written and what it does. Stupid functions printing out multiples of 5 and 3 or whatever is dumb
Mike thanks for the feedback. You are right, its really not necessary to ask these questions, I live in the valley and I have given many interviews. Unfortunately , most of them would ask such questions and you need to be prepared for it
@@Techsithtube Yes you are right that these are the type of questions many fools ask candidates but it is ridiculous to think these questions have any correlation to a developer's ability to develop good software. I worked with many developers who could answer these questions easily and when you hire them they write garbage. Then you have developers who get nervous when these questions are asked on interviews but you work with them and you see they are very good. It is time for experienced developers to ask smart questions during interviews not these coding questions designed to humiliate some people
Excellent mock video! Thanks for sharing. May I know what kind of software are you using for the mock? The one that can shows the css layout and the javaScript FuzzBuzz.
I have been a software engineer for 25 years mostly focused on UI. And I noticed you laugh when you say "don't use tables or anything like that". There is a HUGE misconception on tables, but not only in the people who use them, but also in the people who don't use them. Tables are there for a reason, and its tabular data. I know you can arrive at similar solutions using other entities and CSS. But that doesn't mean tablets are evil. I understand that in this particular case tables are an obviously bad choice. But never the less, if I'm interviewing someone if they don't know which is the place for tables. That is a really bad sign. My two cents :)
for the last toy kid problem can we do like this? function lastKid(n, k, i) { if (k < n) { console.log(k) } else { console.log(k % n) } } lastKid(3, 5, 1)
I like it :) I hope one day making such interview like this here I'm sure i'll be great because i love this field so much thanks techsith and thanks to the man on the other side
Not at all representative of how modern programmers work. Getting the interviewee to talk through some code they had previously written would be much more instructive. function getLastKid(n, k, i) { while (k>0) { k -= 1; if (k==0) {return i;} i += 1; if (i > n) {i = 1;} } }
Hello sir, I have some question in my mind that recently i have left my first job within 10 month bcz of some internal team politics ,and they forced me to leave my job,But when i will go for the next job interview what should be the best answer for me when Interviewer ask, why did you left your job.??
I followed along with all the interview questions and didn't really have any issues except I struggled with the the toy algorithm, and I feel really dumb for it lol. Especially considering there's guys in the comments doing it with 1 line...
For the toy problem, here's my O(1) one-liner: const getLastChild = (n, k, i) => (k + i - 2) % n + 1; For the common divisor problem, my recursive solution is: function getGCD(num1, num2) { const biggerNum = Math.max(num1, num2); const smallerNum = Math.min(num1, num2); if (num1 === num2) return 1; if (smallerNum === 0) return 1; const remainder = biggerNum % smallerNum; if (remainder === 0) return smallerNum; return getGCD(smallerNum, remainder); }; edit: getGCD is inspired by Euclidean algorithm. It's not magic.
Год назад
Nice solutions. One more improvements for getGCD function should be that the calculation of smallerNum = num1 + num2 - biggerNum; instead of using Math.min function which may take much more time accordingly
The last question is wrong... if you had the example as 6, 4, 1 the expected result would be kid 4. However, with his else statement, you will get 6 which is not correct. They did not go through and check other use cases which is why this is wrong. Now his answer for the top case is correct. If anyone has a good answer to fix the bottom case, then post a response. Otherwise, this is my recursive method. function getLastKid(_numKids, _numToys, _start) { if (_numToys === 1) { return _start; } else { let start = null; if ( _start === _numKids ) start = 1; else start = _start + 1; return getLastKid(_numKids, _numToys - 1, start); } }
greater comon diviser exercise: function foo(a,b){ let val = Math.min(a,b); for(let i=val;i>0;i--){ if(a%i==0 && b%i==0){ return i; } } } console.log(foo(8,24)); Can I sold it like this?
So I am freelancer and if I have a front end interview actually I can do this in 2 minutes using function probramming so you can put a number argument. at the end I ALWAYS FIRE FROM INTERVIEW.
What is "null" and why is its data type an object for no reason at all since its just an assignment value or we can say "an unintentional absence of any object value" !!
the last exercise is not right ! take 5 kis, four toys and start from position 3 . the function he wrote will yield 7 the answer is 1 . I wrote this : function getPosition(kids, toys, position) { for (let i = toys; i > 0; i -= 1) { if (position >= kids) { position = 0; } if (i === kids) continue; position += 1; } return position; }
function lastKidPosition(t,k){ var position = (t%k); if(position===0){ console.log(k); }else{ console.log(position);} } lastKidPosition(5,3); this gonna work perfect i guess /* t- no. of toy k- no of kid */
I have a doubt In a web dev interview or react js interview For Ds algo round , can we use java for writing our code instead of js. And for other rounds i will use js. I mean they will provide multiple languages options right in ds algo round ?
great series -- i've watched 3 so far and all candidates fail on being verbal enough to explain their coding while they are coding... since interviews are looking for how you approach problems along with the correct solutions, candidates do themselves a dis-service by not speaking their thoughts...
True that, most people knows lot of stuff , however they are either unable to explain/elaborate or dont find a need to do so. I think that is a grave mistake , often that is the reason they fail interviews.
Nice video, thanks for the interviews. Would you say that i will need to know all the code by hard from the css section? Also is there a general guideline, when to use flex or grid and when to use the whole transform and so on, because i could write it in flex or like the interview participant, but i am not sure when to use what?
Yes for CSS, you need to have all the syntax in your head so that you can smoothly code. You should use flex or grid but always talk to your interviewer so that they know why you are using this.
if(true) { var y=8; console.log(y); let y=9; } o/p:'y' is already been declared MyQuestion:is it run time error or compile time error. I know javascript execute code line by line why it does not printing y=8 ??then throw error
if the start position is 3, then the first kid will receive the last toy, position 1. This algorithm will return 4 instead. Are we not returning the position of the last kid??
if any of are curious about the topics to review before any Frontend developer interview, then check this out: ruclips.net/video/K0GtyweTbTw/видео.html
I went for a job interview and the manager said, "We're looking for someone who is responsible."
"Well I'm your man," I replied.
"In my last job, whenever anything went wrong,
they said I was responsible."
Wow, they took your word very seriously. :)
lol :D
🤣🤣🤣
🤣🤣🤣🤣
HHH really!
The anxiety of wanting to tell him his last if statement in fizzbuzz should of been the first was to much for me to handle. Sweet video, love your work.
Yeah, but I liked his solution of concatenating the string. It fits the elements of the problem. DRY, why introduce a 3rd condition when the first two handles it. I also like dividing by 15, I usually break that out into two separate conditions.
body {
box-sizing: border-box;
}
.squares {
display: flex;
}
.square {
width: 50px;
height: 50px;
border: 1px solid;
display: flex;
justify-content: center;
margin: 5px;
}
.square .circle {
width: 20px;
height: 20px;
border: 1px solid;
border-radius: 10px;
margin: auto;
}
last question:
function getLast(kids, toys, start){
let last = (start + toys -1 )%kids
return last || kids
}
console.log(getLast(3,5,1))
your content is the best man. Your javascript tutorials and javascript interview videos helped me get two job offers. Incidentally a question about self invoking functions came up right after i watched the video for it.
Keep up the good work, friend!
Please do a small favour for us.
While mocking interview, please try to show answer i.e. output in debugger tool or anywhere.
It will be very helpful for us. If possible, please do it
A simple solution to the kids/toys algorithm:
const kids = 3;
const toys = 5;
const startPosition = 1;
const toyReciever = Math.floor((toys / kids) + startPosition);
Nice solution :)
4 kids, 3 toys, startPosition 1, the result should be 3 and not 1
@@mariaab.1154 right
Last problem doesn't need the if-else
getLastKid = (n, k, i) => (k + i - 2)%n + 1;
It could be just (k + i -1)%n but this fails when the kid is the last because mod is 0. So it can also be:
last = (k + i -1)%n ; return last == 0 ? n : last ;
can you pls explain how it works
same thing here ,
const lastToy = (Children,noOfToys,indexOfFirstChild) =>{
return (noOfToys % Children) + (indexOfFirstChild-1)
console.log(Children)
}
console.log(lastToy(7,1,7))
I really liked the way you interview, helped him/giving hints on what can be done and also telling if there are better ways of doing it
Too many people commenting using the luxury of hindsight.
I would like to hear this music play while I'm solving interview problems.
Regarding the solution provided by the interviewee for greatest divisor , the solution won't fail but there is an overhead here. Instead of starting from mid of max we should start from mid of min. We are talking about "greatest COMMON divisor". Key is common. Means it should be a divisor of min also along with max. And divisor of min cannot be greater than half of min.
Good Point Hardeep. thanks for sharing!
I don't understand why mid is needed in the first place. I have solved it in a function, by checking which parameter is greater and lesser and assigning them to max and min variables respectively. Then checking if they are both positive or one of them is negative with an if statement, If they are both positive I would run them through a for loop counting from MAX down to 1 and in the for loop code block - an IF statement checking if the remainder from dividing max%index && min%index === 0. If so return the index. And if either of the parameters are negative then just reverse the for loop.
Hi TechSith, thank you for all the support by sharing your experience and thoughts. For the question of Creating two adjacent squares with a centered circle problem, I have tried the same in a different way. Can you review it, please?
HTML:
//CSS
.square{
width: 50px;
height: 50px;
border:1px dashed red;
padding:0;
display:inline-block;
margin:10px;
}
.circle{
width: 10px;
height: 10px;
border:1px solid black;
border-radius:50%;
margin:20px auto;
background-color:red;
}
Thank you very much.
I love how friendly the interview is, nice one. thanks for the amazing interview man
Find my solution below for the toys problem: I used i=(i+1)%lengthofarray approach to iterate through a circular array.
const a=3;
const k=5;
var index=0;
const c=[];
const d=[];
for(let i=1;i
const getLastChild = (n, k, i) => (k + i - 2) % n + 1; ....does the same thing in O(1) time
The hold music is soooooo soothing XD
Your knowledge of JS is pretty good BUT the last task didn't complete. The solution is wrong and returns incorrect values. e.g (3, 5, 3) returns 4.
I would like to suggest the alternative for 2nd css query
/***** HTML *****/
/***** css *****/
.parent-square {
display: flex;
flex-direction: row;
}
.square {
flex: 1;
border: 1px solid #000;
height: 100px;
display: flex;
align-items: center;
justify-content: center;
}
.square span {
flex-basis: 50px;
border-radius: 100%;
height: 50px;
border: 1px dotted;
}
Note : as flex feature introduced, you can use flex instead of floats, and to vertically and horizontally center the
element, you can use align-items: 'center' or justify-content:'center'' rather then absolute,transform and all those
It's worth noting that `.sq:first-child` is prone to breaking. If you add a div above the , it'll stop selecting.
It's trying to select an element that has a class of `sq` AND is the first child of its parent.
Also, if you use the same class name elsewhere and it too is a first child of its parent, it'll be selected.
To fix it you'd need to raise the specificity on it.
Today I went for an interview and I was able to crack this round. Waiting for final round. Thanks for your videos. Still waiting for your response regarding mock interview
I have a doubt
In a web dev interview or react js interview
For Ds algo round , can we use java for writing our code instead of js.
And for other rounds i will use js.
I mean they will provide multiple languages options right in ds algo round ?
Hello please tell me how many rounds are there in front end developer interview
HTML:
CSS:
.container{
display:grid;
grid-template-columns:50px 10px 50px;
}
.square{
height:50px;
border:1px solid black;
}
.circle{
position:relative;
width:20px;
height:20px;
border-radius:50%;
border:1px solid black;
left:25%;
top:25%;
}
The question regarding getting the greatest common divisor between two number could be simplified as follows:
function getTheGreatestCommonDivisor(x,y){
let maxPara=Math.max(x,y);
let Array=[]
for (let i=1;i
Modibo, good solution. you can also make it recursive .
we dont need to push to array since were looking for Greatest means 1, we can just use GreatestCommonDivisor = i;
function findTheBiggestOne(a, b) {
let min = a > b ? b : b;
let max = a > b ? a : a;
for (let i = max; i > 0; i--) {
if (max % i === 0 && min % i === 0) {
return i;
}
}
}
console.log(findTheBiggestOne(2, 3));
i think this way is more better............
The following solution to kids toys problem worked for all the cases I tried:
function lastKidWithToy(k, t, p) {
if(pt){
var position = t + p - 1
} else {
var position = t%k + p -1
}
console.log(position > k ? position-k : position);
} else {
console.log("Invalid position");
}
}
lastKidWithToy(7,8,7);
great solution Anupriya. Thanks for sharing
@@Techsithtube Wouldn't this still fail tho for example the numbers were 3, 3, 1. Because 3%3 = 0, 0 + 1 - 1 = 0
My take on the first function.
function fizzy(num){
let str = '';
if(num===0){
return;
}
if(num>0){
if(num%3==0){
str+='Fizz'
}
if(num%5==0){
str+='Buzz'
}
console.log(num+' '+str)
return fizzy(num-1);
}
}
fizzy(59);
i have did different approche :
let temp = 0;
let arr;
function distributeToys(n, k, i){
let t = k;
if(!t) { temp = 0; return
}
if(temp < k){ arr = new Int16Array(n); temp = k }
for(let index = i; index < n; index++){
if(t == 0) return
arr[index] += 1;
t--
}
distributeToys(n,t,0)
}
if we did : distributeToys(3, 5, 0) we get : Int16Array(3) [2, 2, 1]
this algorithm returns an array of how much each kid get of toys
This series is good.... it would be much better if you can create a series on polyfills. Like how to create all es6 or 7 syntax with es5(example: class, extend etc.). it will help some people to deep dive in prototypes and its uses.
Yes I think that would be interesting. I will consider it. Thanks for suggestion .
Last question Solution for all Cases:
function callme(kids,toys,position)
{
let lasttoy;
if(toys>=kids)
lasttoy = (toys%kids)+position-1;
else if(toys==kids)
lasttoy = position-1;
else
lasttoy= toys+position-1
return lasttoy>kids ? lasttoy-kids : lasttoy;
}
callme(6,3,6)
const gcd = function (a, b) {
if (b === 0) return a;
return gcd(b, a % b);
};
gcd(5,25)
Disclaimer: i paused the video and write my answer
First loop through the given range
Okay first check if a number is multiple of both 5 and 3 then return fizzbuzz
Else if check for multiple of only 3 then return fizz
Else if check for multiple of 5 then return buzz
Else return the number...
You can use in built-in functions as well but above answer is easy to understand when you are a beginner
hi! Can we do the css problem other way? I have done it other way.
.squares {
border: 2px solid black;
width: 50px;
height: 50px;
text-align: center;
display: inline-block;
margin-right: 10px;
}
.squares div {
border: 2px solid black;
width: 20px;
display: inline-block;
height: 20px;
margin: 10px;
border-radius: 10px;
}
.outerline {
text-align: left;
}
.squares:last-child {
margin-left: 0px;
}
I think that without box-sizing and transform property, this works perfectly.
I have been a developer in Silicon Valley for over 25 years and I have been a lead UI developer and built many products. I have always been 1 of the top front end developers at every company I have worked at. These interview questions are worthless and stupid. They tell you nothing about how good a developer this guy really is. Writing some dumb little function in 5 minutes is not what makes the best developer valuable. The best developers can build a product from the ground up and understand how to design the code for maintainability and make it scale over the years. This interviewer guy in this video must be one of those consulting hacks that build some garbage and then leaves the company onto his next hacking project where he builds garbage that someone else has to clean up. You want to know if someone is a good developer, then look at some source code they have written and see how well it is commented, how well it is written and what it does. Stupid functions printing out multiples of 5 and 3 or whatever is dumb
Mike thanks for the feedback. You are right, its really not necessary to ask these questions, I live in the valley and I have given many interviews. Unfortunately , most of them would ask such questions and you need to be prepared for it
@@Techsithtube Yes you are right that these are the type of questions many fools ask candidates but it is ridiculous to think these questions have any correlation to a developer's ability to develop good software. I worked with many developers who could answer these questions easily and when you hire them they write garbage. Then you have developers who get nervous when these questions are asked on interviews but you work with them and you see they are very good. It is time for experienced developers to ask smart questions during interviews not these coding questions designed to humiliate some people
function gcd(a,b){
if (a === 0)
return b;
return gcd(b % a, a);
}
ca you please please make a couse/tutorial on the whole firebase sdk? specifically on cloud functions and storage ?
Sure I think that would be a good tutorial series. I will try to make it soon.
Excellent mock video! Thanks for sharing. May I know what kind of software are you using for the mock? The one that can shows the css layout and the javaScript FuzzBuzz.
I usually use Jsfiddle for css, html and js interviews. For only js interviews I use coderpad
I have been a software engineer for 25 years mostly focused on UI. And I noticed you laugh when you say "don't use tables or anything like that".
There is a HUGE misconception on tables, but not only in the people who use them, but also in the people who don't use them. Tables are there for a reason, and its tabular data. I know you can arrive at similar solutions using other entities and CSS. But that doesn't mean tablets are evil.
I understand that in this particular case tables are an obviously bad choice.
But never the less, if I'm interviewing someone if they don't know which is the place for tables. That is a really bad sign.
My two cents :)
I don't think the last function is quite right. (3 kids , 7 apples, from position 7.) This video is quite interesting anyway.
I am glad you like it peng. If you know the right solution . Please do share!
for the last toy kid problem can we do like this?
function lastKid(n, k, i) {
if (k < n) {
console.log(k)
}
else {
console.log(k % n)
}
}
lastKid(3, 5, 1)
really great video but the logo at the middle of the screen is kinda obstructing a few things
const gcd = function(a, b) {
if (!b) {
return a;
}
return gcd(a % b);
};
console.log(gcd(6, 4)); // 6
I like it :)
I hope one day making such interview like this here I'm sure i'll be great because i love this field so much
thanks techsith
and thanks to the man on the other side
How was it ? Did you accomplish your dreams?
who wants to remember this shit when things are available on the internet, You have to improvise and put in your logic and variables.
Nice video ...plz continue the series
For toys problem. Simple just: k%n ex: 5%3 = 2, 3%5 = 3 if i=1 case
perfect :)
@@Techsithtube likes your videos. Please make tutorial of redux-form and redux-saga
i smell eloquent JavaScript
Here's my solution
First of all, think about the order and write the Fizz buzz at the top of the condition
function nums(){
for (let i = 1; i
What about mock interviews for senior frontend developers?
I should create one. :)
Not at all representative of how modern programmers work. Getting the interviewee to talk through some code they had previously written would be much more instructive.
function getLastKid(n, k, i) { while (k>0) { k -= 1; if (k==0) {return i;} i += 1; if (i > n) {i = 1;} } }
The first javascript function fizzbuzz is actually easy ...
Hello sir,
I have some question in my mind that recently i have left my first job within 10 month bcz of some internal team politics ,and they forced me to leave my job,But when i will go for the next job interview what should be the best answer for me when Interviewer ask, why did you left your job.??
I followed along with all the interview questions and didn't really have any issues except I struggled with the the toy algorithm, and I feel really dumb for it lol. Especially considering there's guys in the comments doing it with 1 line...
For the toy problem, here's my O(1) one-liner: const getLastChild = (n, k, i) => (k + i - 2) % n + 1;
For the common divisor problem, my recursive solution is:
function getGCD(num1, num2) {
const biggerNum = Math.max(num1, num2);
const smallerNum = Math.min(num1, num2);
if (num1 === num2) return 1;
if (smallerNum === 0) return 1;
const remainder = biggerNum % smallerNum;
if (remainder === 0) return smallerNum;
return getGCD(smallerNum, remainder);
};
edit: getGCD is inspired by Euclidean algorithm. It's not magic.
Nice solutions. One more improvements for getGCD function should be that the calculation of smallerNum = num1 + num2 - biggerNum; instead of using Math.min function which may take much more time accordingly
Display flex(parent element) and margin auto(child element) can be the best solution to centre anything?
Yes Flex would an easy choice however sometimes in an interview they might ask you to avoid flex.
Very good channel.Very good tutorial. Always keep on making such videos.
who else would have failed the on-the-spot greatest common divisor question?😄👋🏽👋🏽
It is a hard one , especially if you have to come up with a quick solution. Usually people with math background gets it quickly.
The first condition should validate both multiple
The last question is wrong... if you had the example as 6, 4, 1 the expected result would be kid 4. However, with his else statement, you will get 6 which is not correct. They did not go through and check other use cases which is why this is wrong. Now his answer for the top case is correct. If anyone has a good answer to fix the bottom case, then post a response. Otherwise, this is my recursive method.
function getLastKid(_numKids, _numToys, _start) {
if (_numToys === 1) {
return _start;
} else {
let start = null;
if ( _start === _numKids ) start = 1;
else start = _start + 1;
return getLastKid(_numKids, _numToys - 1, start);
}
}
Scott, you are right. I did miss that error. Thanks for pointing it out.
// it does not work only in one case when noOChildren ==noOfToys and indexOfFirstChild =1
const lastToy = (Children,noOfToys,indexOfFirstChild) =>{
return (noOfToys % Children) + (indexOfFirstChild-1)
console.log(Children)
}
console.log(lastToy(7,1,7))
greater comon diviser exercise:
function foo(a,b){
let val = Math.min(a,b);
for(let i=val;i>0;i--){
if(a%i==0 && b%i==0){
return i;
}
}
}
console.log(foo(8,24));
Can I sold it like this?
nice work. .can u please continue the series it wll help me more
Yes I have will start releasing from next week.
So I am freelancer and if I have a front end interview actually I can do this in 2 minutes using function probramming so you can put a number argument. at the end I ALWAYS FIRE FROM INTERVIEW.
Kindly make some more videos for javascript interview ?
For the CSS question, correct me if I'm wrong, but wouldn't this be a more efficient way of doing this?
.sq {
width: 50px;
height: 50px;
border: 1px solid red;
display: inline-block;
position: relative;
margin: 0 5px;
box-sizing: border-box;
}
.sq:after {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50% ,-50%);
background-color: yellow;
min-width: 20px;
min-height: 20px;
border-radius: 50%;
}
How should you answer that react question?
Thank you for front end interview
What is "null" and why is its data type an object for no reason at all since its just an assignment value or we can say "an unintentional absence of any object value" !!
no i didn't learn anything :D it just made me feel good about my skills at that point
My solution to the circles in squares - codepen.io/atlasxmaxima/pen/rZoxwp
the last exercise is not right ! take 5 kis, four toys and start from position 3 . the function he wrote will yield 7 the answer is 1 .
I wrote this :
function getPosition(kids, toys, position) {
for (let i = toys; i > 0; i -= 1) {
if (position >= kids) {
position = 0;
}
if (i === kids) continue;
position += 1;
}
return position;
}
Please continue with interview series
WIll keep doing it. thanks for watching!
In Kids program challenge, As per the solution given there, it will fail if(n%k==0) - it should return n in that case.
Thanks for correcting it. Yes you are right.
function lastKidPosition(t,k){
var position = (t%k);
if(position===0){
console.log(k);
}else{ console.log(position);}
}
lastKidPosition(5,3);
this gonna work perfect i guess
/* t- no. of toy
k- no of kid */
Vary smart xDDDD Hare in Bulgaria front end interns are smarter than the interviewer
function findGCD(m,n) {
let divisor = Math.ceil(Math.max(m,n) / 2);
while(divisor > 0) {
if(m % divisor === 0 && n % divisor === 0 ) {
console.log(divisor);
return divisor;
}
divisor--;
}
}
Interesting solution . thanks for sharing
Great video... Thanks.
Are you still creating videos in 2021?
on which platform you are running your code?
Content is not clear, Can you recheck the video
hey techsith can you add the answers to your questions? I cant seem to find them in the description
We could use continue.
I have a doubt
In a web dev interview or react js interview
For Ds algo round , can we use java for writing our code instead of js.
And for other rounds i will use js.
I mean they will provide multiple languages options right in ds algo round ?
same question ⁉️
I think that the last solution may get a wrong result when input is 3,8,3
Can we expect these questions for a product based company?
great series -- i've watched 3 so far and all candidates fail on being verbal enough to explain their coding while they are coding... since interviews are looking for how you approach problems along with the correct solutions, candidates do themselves a dis-service by not speaking their thoughts...
True that, most people knows lot of stuff , however they are either unable to explain/elaborate or dont find a need to do so. I think that is a grave mistake , often that is the reason they fail interviews.
4 years of experience and can't do fizz buzz!
Nice video, thanks for the interviews.
Would you say that i will need to know all the code by hard from the css section? Also is there a general guideline, when to use flex or grid and when to use the whole transform and so on, because i could write it in flex or like the interview participant, but i am not sure when to use what?
Yes for CSS, you need to have all the syntax in your head so that you can smoothly code. You should use flex or grid but always talk to your interviewer so that they know why you are using this.
okay, thank you for the quick answer.
The solution to last problem is not correct , don't forget position can be anything , we are not starting from initial all the time
big fan sir
if(true)
{
var y=8;
console.log(y);
let y=9;
}
o/p:'y' is already been declared
MyQuestion:is it run time error or compile time error.
I know javascript execute code line by line why it does not printing y=8 ??then throw error
JavaScript doesnt allow you to declare same variable twice inside the same block. that is why the error.
It's interesting...
kid>=toy ? toy : (toy%kid)+(start-1)
Nice Solution:)
if the start position is 3, then the first kid will receive the last toy, position 1. This algorithm will return 4 instead. Are we not returning the position of the last kid??
Please don't use background music.
I only used in this video.
@@Techsithtube yupp, I observed it, thanks for your video tutorials
@@Techsithtube yupp, I observed it, thanks for your video tutorials
function findLastKid(n, k, start) {
let kids = [];
let toys = [];
for (let i = start; i
const lastKid = (n, k, i) => (i + k - 1) % n;
It's good
Nice
On the 1st 1 I think he just got nervous cuz he's being interviewed on the spot. Which is NOT FAIR because that is NOT how people develop at jobs.
That is true. but its unfortunate that interviews always ask thinks that you don't uses on daily bases. That is why you need to be always prepared.
Last Question k%n + i - 1
thanks for sharing your solution!
I dont see solutions
Thanks brother Allah bless you Ameen
Thank you for watching Shuja!
@@Techsithtube hey bro, is math required in javascript that much?
if any of are curious about the topics to review before any Frontend developer interview, then check this out: ruclips.net/video/K0GtyweTbTw/видео.html