How to Ace the Fibonacci Sequence Interview Question in JavaScript

preview_player
Показать описание
It's a super secret project. More details coming soon!

Hello world and welcome back! Here's one of my favorite algorithm problems solved in four different ways.

👇👇👇👇FIND MORE USEFUL INFO HERE👇👇👇👇
I've been coding for at least 7h/day for the past 3 months and learning so much (not just coding!). This is my last assignment for the coding bootcamp BEFORE I GRADUATE WOO-HOO and I wanted to share some of the tips and tricks with you, of course! 🤓 Hope you're surviving and at least sometimes finding moments for thriving in these absurd times ❤️

🎥 Equipment, 📚 Book recommendations and 🏆 Competition Gear

🙃 SAY HI!

💵 SAVE MONEY 💵

🎶 MUSIC 🎶
Amphibian - Lofive
Kids On the Porch (Instrumental Version) - Iso Indies
Mindset - Issue AB
Old Grump - Smartface
The Light from Within - Howard Harper-Barnes
Wave Crest - Airae

Images
All other images licensed through wikimedia Creative Commons license.

🔬🔬🔬RESEARCH AND RESOURCES🔬🔬🔬
Better solutions (not in JavaScript) with Java, Python and Go - solutions are based on Matrix Exponentiation and plain ol' beautiful math!

To better understand Big O notation:

In-depth explanation of this time complexity

Variations on the solutions in the video:

Another hot take that I just didn't vibe with

Fibonacci Explained in multiple programming languages

FTC and KO: Not sponsored. Some of the above links are affiliate links, meaning I earn a small percentage (1-3%) of sales made via those links, but it doesn’t cost you anything extra!
Рекомендации по теме
Комментарии
Автор

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!

twisteramaify
Автор

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.

jbanks
Автор

Just three months and you've learned a lot of concepts. That's great.

jamjam
Автор

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??

pixelsvector
Автор

i have no idea what you are talking about but it is interesting

justinn
Автор

1 minute in and I am realizing how stoopid I am :(

SquidRider
Автор

To really impress the recruiters, you program the code in assembly on TRS-80 computer.

ahndeux
Автор

make more coding videos and love how in the description you say hello world

nas
Автор

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.

malinichandran
Автор

Oh wow. Programming! My favorite language is JS!

jamjam
Автор

You should do these types of videos more

toxxmoloi
Автор

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.

MultiDude
Автор

I got that Einstein book 👍also I like this hair style on you 😍

LonelyGamr
join shbcf.ru