Facebook iOS Interview Question (Meta - Swift) - 2022

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 พ.ย. 2024

ความคิดเห็น • 49

  • @iOSAcademy
    @iOSAcademy  2 ปีที่แล้ว +7

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

    • @mateo5677
      @mateo5677 2 ปีที่แล้ว

      MORE ASAP 🙏🏽

  • @simpleinterest360
    @simpleinterest360 2 ปีที่แล้ว +15

    Plz continue this algo and design pattern series

  • @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.

  • @mateo5677
    @mateo5677 2 ปีที่แล้ว +1

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

  • @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.

    • @iOSAcademy
      @iOSAcademy  2 ปีที่แล้ว

      Thanks, much appreciated

  • @Baradach1000
    @Baradach1000 2 ปีที่แล้ว +2

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

  • @juleannynavas9111
    @juleannynavas9111 2 ปีที่แล้ว +1

    Amazing! This is incredible educational! thanks a bunch!

  • @tutosCasuales
    @tutosCasuales 2 ปีที่แล้ว +1

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

  • @Avolua
    @Avolua 2 ปีที่แล้ว +1

    Happy new year sir. Thank you!

  • @RsAKingOfLife
    @RsAKingOfLife 2 ปีที่แล้ว +1

    These videos are amazing, thank you

  • @KailashAnand06
    @KailashAnand06 2 ปีที่แล้ว +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  2 ปีที่แล้ว

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

    • @KailashAnand06
      @KailashAnand06 2 ปีที่แล้ว +1

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

    • @iOSAcademy
      @iOSAcademy  2 ปีที่แล้ว

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

  • @EricEric2004
    @EricEric2004 2 ปีที่แล้ว +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  2 ปีที่แล้ว +1

      You are correct. I forgot to mention this

  • @dostonbek.rustamov
    @dostonbek.rustamov 2 ปีที่แล้ว

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

  • @sarathsha7543
    @sarathsha7543 2 ปีที่แล้ว +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  2 ปีที่แล้ว +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!

  • @blinddirector
    @blinddirector 2 ปีที่แล้ว +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  2 ปีที่แล้ว

      Nice!

    • @mike_zander
      @mike_zander 2 ปีที่แล้ว

      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 2 ปีที่แล้ว +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  2 ปีที่แล้ว

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

  • @dennycad7859
    @dennycad7859 2 ปีที่แล้ว +1

    Amazing 🤩

  • @LukeSS
    @LukeSS 8 หลายเดือนก่อน

    This algorithm does not work for a 3x4 matrix

  • @codechamp2599
    @codechamp2599 2 ปีที่แล้ว +2

    damn

  • @cronx1337
    @cronx1337 2 ปีที่แล้ว +2

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

    • @ferdiangunawan1237
      @ferdiangunawan1237 2 ปีที่แล้ว +2

      swift is gold, react native is trash

    • @AllanSpreys
      @AllanSpreys 2 ปีที่แล้ว

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

    • @cronx1337
      @cronx1337 2 ปีที่แล้ว +1

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

    • @iOSAcademy
      @iOSAcademy  2 ปีที่แล้ว +5

      We’re just hear for the algorithms