iOS interview questions reported at Meta
16 questions candidates reported being asked at Meta. Anonymous and unverified, so treat it as a hint of what to expect.
- What is the difference between
struct,class, andactor? - What is an Optional in Swift, and what is it internally?
- Escaping vs non-escaping closures?
- How does ARC work, and how is it different from garbage collection?
- Given two UIViews, find their closest common superview. How do you handle a view that is its own ancestor, or views in different trees?
- Write a function that checks whether one CGRect fully contains another, then explain how you decide whether a touch lies inside a view that sits inside a scrolled parent.
- How does the client learn about new data: polling, long polling, WebSocket, server-sent events or push? How do you choose?
- Design the client of a flight booking app: search, seat hold, payment and confirmation. How do you handle a timed hold, double taps and a payment that fails?
- Two-sum: given an array and a target, return the indices of two elements that add up to it. How do you get from O(n²) to O(n), and which edge cases do you test?
- Merge overlapping intervals: [[1,3],[8,10],[2,6],[15,18]] becomes [[1,6],[8,10],[15,18]]. How do you do it, and when do touching intervals count as overlapping?
- Write an Array extension that removes every element that appears in a second array. What is the complexity, and what if the elements are only Equatable?
- Add two non-negative numbers given as decimal strings, without converting them to integers. Why can you not just use Int, and how does the carry loop work?
- Given a string with brackets, remove the fewest parentheses to make it valid. How do you count them, and how do you build the fixed string?
- Next permutation: rearrange an array into the next lexicographically greater order, in place. Walk through the algorithm.
- Reverse a singly linked list in Swift, iteratively and recursively. What can go wrong with long lists?
- Implement a hash map from scratch (get, set, remove), then extend it: what do you test and how does resizing work?