Hi Yanjaa, Love your video SO MUCH and I learned a lot!! Your first solution is actually ALMOST optimal and almost the same as your last solution. Just because your first solution had a for loop, does not mean that it is naive. For your first solution, instead of pushing to the array, just do what you do in your last solution and put [arr[0], arr[1]] = [arr[1], arr[0] + arr[1]]. Optimal solution: // Space: O(1) // Time: O(n) function getNthFib(n) { if (n === 1) return 0; let arr = [0, 1] for (let i = 2; i < n; i++) { [arr[0], arr[1]] = [arr[1], arr[0] + arr[1]]; } return arr[1] } I would be fascinated to learn what memory techniques you utilize to memorize these algorithms!
Isn't fib(0) 0 and fib(10) 55. i mean for the fib number sequence that you have written, the corresponding number sequence should start from 0 right. I am a newbie trying to learn recursion so please correct me if I am wrong.
Can you PLZPLZPLZPLZPLPZLPZLPZL make a video about what memory techniques to use in order to memorize these algorithmic questions! I'm also prepping for interview questions, but I am new to memory techniques, so my memory palace doesn't seem to be as effective as it could be. I place each question and can remember the outline of each solution, but I get tripped up with the edge cases and stuff :( A video on this would literally change my life.
Hi Yanjaa,
Love your video SO MUCH and I learned a lot!!
Your first solution is actually ALMOST optimal and almost the same as your last solution. Just because your first solution had a for loop, does not mean that it is naive. For your first solution, instead of pushing to the array, just do what you do in your last solution and put [arr[0], arr[1]] = [arr[1], arr[0] + arr[1]].
Optimal solution:
// Space: O(1)
// Time: O(n)
function getNthFib(n) {
if (n === 1) return 0;
let arr = [0, 1]
for (let i = 2; i < n; i++) {
[arr[0], arr[1]] = [arr[1], arr[0] + arr[1]];
}
return arr[1]
}
I would be fascinated to learn what memory techniques you utilize to memorize these algorithms!
Thank you! That's really helpful
Yes! Super down to see more coding vids and how you learn. I've been going at it off and on for a few years now doing the self taught route.
Hey yanjaa,
you as a memory athlete what memory techniques did u use when learning to code? and
what did you memorise using the techniques??
Just three months and you've learned a lot of concepts. That's great.
1 minute in and I am realizing how stoopid I am :(
i have no idea what you are talking about but it is interesting
make more coding videos and love how in the description you say hello world
I super agree
You should do these types of videos more
Oh wow. Programming! My favorite language is JS!
Isn't fib(0) 0 and fib(10) 55. i mean for the fib number sequence that you have written, the corresponding number sequence should start from 0 right. I am a newbie trying to learn recursion so please correct me if I am wrong.
To really impress the recruiters, you program the code in assembly on TRS-80 computer.
Can you PLZPLZPLZPLZPLPZLPZLPZL make a video about what memory techniques to use in order to memorize these algorithmic questions! I'm also prepping for interview questions, but I am new to memory techniques, so my memory palace doesn't seem to be as effective as it could be. I place each question and can remember the outline of each solution, but I get tripped up with the edge cases and stuff :(
A video on this would literally change my life.
Guess whose back, Back again
I got that Einstein book 👍also I like this hair style on you 😍
Funny how much we have in common
😍👏👏