Facebook iOS Interview Question (Meta - Swift) - 2022

Поділитися
Вставка
  • Опубліковано 19 гру 2024

КОМЕНТАРІ • 49

  • @iOSAcademy
    @iOSAcademy  3 роки тому +7

    Like my teaching style? Check out iOS Academy+ iosacademy.io/plus

    • @mateo5677
      @mateo5677 2 роки тому

      MORE ASAP 🙏🏽

  • @mykytakhlamov
    @mykytakhlamov Рік тому +1

    Great topic, thanks!
    I just add one more thing - change left, top, right, bottom variables not at the end of the while loop but each edge after for in loop.
    So we change top += 1 after left-right,
    right -= 1 after top - down,
    bottom -= 1 after right - left,
    left += 1 after up.
    So now we don't need to use +/- 1 in the 'from' argument in the 'stride' function.

  • @simpleinterest360
    @simpleinterest360 3 роки тому +15

    Plz continue this algo and design pattern series

  • @airysm
    @airysm Рік тому

    This was such a great video. This has easily become my favorite iOS dev channel

  • @mzain823
    @mzain823 2 роки тому +1

    Honestly I’m inspired. Your confidence and approach are highly admirable Afraz. Thank you.

  • @mateo5677
    @mateo5677 2 роки тому +1

    more of this please! ASAP! I have my interviews with facebook and google soon

  • @Avolua
    @Avolua 3 роки тому +1

    Happy new year sir. Thank you!

  • @Baradach1000
    @Baradach1000 3 роки тому +2

    For optimization. Is it possible to simply apply the reserve capacity of total.count to the resulting array?

  • @RsAKingOfLife
    @RsAKingOfLife 2 роки тому +1

    These videos are amazing, thank you

  • @juleannynavas9111
    @juleannynavas9111 2 роки тому +1

    Amazing! This is incredible educational! thanks a bunch!

  • @KailashAnand06
    @KailashAnand06 3 роки тому +1

    hey I have a quick question, if you have created the result array as Array(repeating: nil, count: total), all the values will be nil, and the total count will be 9 anyway. so the code won't even enter the while loop, and in the loop too we have to change the value and not append to the list. I think if we change the while loop condition to check if the last element of the result array is still nil should be a better check!
    great video, please make more of these in the future, im having great fun finding solutions to these questions! thank you!

    • @iOSAcademy
      @iOSAcademy  3 роки тому

      Yep, i forgot to tweak the loop. Answered in a comment below

    • @KailashAnand06
      @KailashAnand06 3 роки тому +1

      @@iOSAcademy oh yeah I didn't check! thanks a lot man, appreciate your efforts and loving your recent content :D

    • @iOSAcademy
      @iOSAcademy  3 роки тому

      @@KailashAnand06 youre welcome!

  • @Simcha11111
    @Simcha11111 2 роки тому +1

    Hey Afraz, I wrote a different solution to this that basically peeled off the outer layer of the matrix one at a time and recursively ran the same function on the inner remaining matrix. I'm curious about your thoughts on this approach. It's only slightly faster since you can always rip the top and bottom rows in O(1), but you can't really say it's faster than O(MN)

    • @iOSAcademy
      @iOSAcademy  2 роки тому +1

      Great solution. Id accept it

  • @tutosCasuales
    @tutosCasuales 3 роки тому +1

    In which stage is this asked? In the phone screen interview or in the onsite?

  • @dostonbek.rustamov
    @dostonbek.rustamov 3 роки тому

    This algorithm return one more element if there are 4 and more rows or columns

  • @dennycad7859
    @dennycad7859 3 роки тому +1

    Amazing 🤩

  • @sarathsha7543
    @sarathsha7543 3 роки тому +2

    Hi I'm Sarath,
    I have one doubt, after changing
    var result = [Int]() // equivalent to result = []
    To
    var result: [Int?] = Array(repeating: nil, count: total) // equivalent to result = [nil, nil, nil, nil, nil, nil, nil, nil, nil] here total value as 9
    now result.count also 9
    then how it will enter in to while condition( result.count(9) < total(9)). ?

    • @iOSAcademy
      @iOSAcademy  3 роки тому +1

      Great question. I forgot to mention that youll change the while loop to check that the last value is still nil. You also wont append, youll need to change values in place with another index pointer. Great catch!

  • @EricEric2004
    @EricEric2004 3 роки тому +4

    This solution has a bug. Try running a simple matrix like [[6,7]], it will return [6,7,6] because it runs the backward append right->left even after appended [6,7]. You need to add intermediate checks too.

    • @iOSAcademy
      @iOSAcademy  3 роки тому +1

      You are correct. I forgot to mention this

  • @blinddirector
    @blinddirector 3 роки тому +5

    The two FB/Meta questions I got (with execution and autocomplete disabled on coder pad)
    QUESTION ONE:
    Define a Multiset that implements the following methods:
    1. add(element)
    2. remove(element)
    3. count(for: element)
    QUESTION TWO:
    Write a function that takes in an input array of houses by the ocean and returns an array containing the indices of houses that can see the ocean (if a taller or equal height house is between a house and the ocean, that house cannot be added)
    // Ocean View
    // Input: [4, 3, 2, 3, 1]
    // Output: [0,3,4]
    //
    // ___
    // 4 | | ___ ___
    // 3 | | | | ___ | |
    // 2 | | | | | | | | ___
    // 1 | | | | | | | | | |
    // ~~~~~ Ocean
    // b0, b1, b2, b3, b4

    • @iOSAcademy
      @iOSAcademy  3 роки тому

      Nice!

    • @mike_zander
      @mike_zander 3 роки тому

      Dude, thank you. What did you do for question 1? Not sure how to approach it.

    • @navyac6289
      @navyac6289 2 роки тому

      Was this asked for the phone interview?

  • @nasir519
    @nasir519 3 роки тому +2

    If you can offer a course where you teach High/Low level design aspect of iOS app, something like iOS/Mobile app architecture level it would be more beneficial. (Paid one is also fine).
    Thanks

    • @iOSAcademy
      @iOSAcademy  3 роки тому

      Hey there! I plan to offer this & more in the coming months

  • @LukeSS
    @LukeSS 10 місяців тому

    This algorithm does not work for a 3x4 matrix

  • @codechamp2599
    @codechamp2599 3 роки тому +2

    damn

  • @cronx1337
    @cronx1337 3 роки тому +2

    Facebook is trash, both as a company, product, and an idea.

    • @ferdiangunawan1237
      @ferdiangunawan1237 3 роки тому +2

      swift is gold, react native is trash

    • @AllanSpreys
      @AllanSpreys 3 роки тому

      If you pass an interview at Facebook, you can work on any of their products including Instagram and WhatsApp.

    • @cronx1337
      @cronx1337 3 роки тому +1

      @@AllanSpreys I did pass their interviews, and Swiftly told them to fuck right off.

    • @iOSAcademy
      @iOSAcademy  3 роки тому +5

      We’re just hear for the algorithms