How to Ace the Fibonacci Sequence Interview Question in JavaScript

Поделиться
HTML-код
  • Опубликовано: 9 ноя 2024

Комментарии • 20

  • @twisteramaify
    @twisteramaify 4 года назад +6

    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!

    • @Yanjaa
      @Yanjaa  4 года назад +1

      Thank you! That's really helpful

  • @jbanks1120
    @jbanks1120 4 года назад +2

    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.

  • @pixelsvector8973
    @pixelsvector8973 4 года назад +5

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

  • @jamjam3448
    @jamjam3448 4 года назад +3

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

  • @SquidRider
    @SquidRider 4 года назад +8

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

  • @justinn9342
    @justinn9342 4 года назад +3

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

  • @nas5834
    @nas5834 4 года назад +1

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

  • @toxxmoloi1873
    @toxxmoloi1873 4 года назад +1

    You should do these types of videos more

  • @jamjam3448
    @jamjam3448 4 года назад +2

    Oh wow. Programming! My favorite language is JS!

  • @malinichandran
    @malinichandran 3 года назад

    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.

  • @ahndeux
    @ahndeux 2 года назад

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

  • @MultiDude4567
    @MultiDude4567 4 года назад +2

    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.

  • @troyvlahakis4731
    @troyvlahakis4731 4 года назад +2

    Guess whose back, Back again

  • @LonelyGamr
    @LonelyGamr 4 года назад +1

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

  • @teth.
    @teth. 4 года назад +1

    Funny how much we have in common

  • @glauberbrasileiro7581
    @glauberbrasileiro7581 4 года назад

    😍👏👏