 What's up guys my name is Michael and welcome to my YouTube channel today We're gonna do another leak code challenge. It's called a Fibonacci number Fibonacci numbers just subscribe as What it says here, you know, you have the sum of the two numbers of the preceding ones you start at zero one F of n f of zero zero f one is one f of n is equal to f of n minus one plus f of n minus two Yeah, that's basically it All you have to do is just do this could be two two lines If n is less than or equal to one Return n because that would be zero and one. Okay else return Fib and minus one plus Fib and minus two Yeah, that's it Wait a minute. Yep. That was it that that's basically it Click the submit button and It should get accepted. Yes, but it is very very slow So there is another the best optimal solution is actually use something called memo is Asian Memo wise So here they have Top-down approach, let's see which is a better one. I don't want to do this way Matrix you can use matrix it Wow That is this way too complicated Yeah, that's way too complicated. I don't think that's a good idea actually log of n. Whoa Wow, okay, I Think it's better to go over memo is Asian because that's much faster It's actually better. Oh This is much better actually. This is a better way Bottom-up approach because then you don't have to recursively call it So it's actually much better if you just do this and then memo wise create your Array and then pre-compute it based on the values like this So using recursion, so I'll use it this way Essentially memorizing is just pre-comp, pre-computation. So you don't have to repeat compute computations. So that's what it is See so I don't want to create it and I don't want that return and memo wise memo wise and Let's do this part Memo wise. Okay, so I'm gonna create a vector Int is gonna have data is gonna have n a Do-do-do-do n plus one actually n plus one and Then I'll do data at one is equal to one Go from two reason why we're going from two is because we want to Memo wise from zero one two and pre add the previous values Together so the previous two values add them up and store that as our memo wise data So I is gonna equal to data I minus one plus data at I minus two Then after that we just return Data at n. Okay. I think this is much better. We're in the code. Let's see what this does. Hopefully no errors Okay, so this it does fits it out correctly submit Do-do-do and it got accepted. So, yeah, that's all I have. Oh, yeah, that's how you do Bit my Nazi number great come subscribe check guys later. Thank you