Hey Clement, how is it going? I've been preparing for internships using algoexpert and sometimes there are some questions that I can't find the answer for. I was wondering if there is a facebook group or something so student could ask their question from you or your team?
I think, initial value for counter should be 2 and the base case check while returning will be n>=1. // time: O(n) | space: O(1) func fib(N int) int { lastTwo := []int{0, 1} counter := 2 for counter = 1 { return lastTwo[1] } return lastTwo[0] } Thank you very much for the tutorial!
one may also optimize a little bit in both space and time complexity if you assume any number below or equal to 2, except 0, will always return 1. fib(int n) { if(n == 0) return 0; else if ( n
how does one know to put n ==2 return 1 or n==1 return 0? like was it base on the first two value being 0, 1 and we just gave it the == 1 and 2 based on the fib(n-1) and fib(n-2) in that order?
You know there is a formula for this soo if you would be asked ever to do this (most unlikely) what's stopping you from using the formula? soo you will have a const time :)))
This website is a waste of money, save your self some and learn to code by yourself, you don't need these so called experts to help you "ace" the interview, if you know how to code, your knowledge will come thru
Uh, everyone learns how to code by themselves. You just learn the basics from school or whatever source you find at first. Then you learn on your own as you code more by getting stuck, hitting the brick wall, struggling, asking questions on stackoverflow, googling for things etc. AlgoExpert certainly helps you to perform better in technical interviews. Even when you're a cs major, it's hard to know everything. The problem is there are all kinds of problems and there is not enough time.