Apple logo

Apple Frontend Engineer Interview Questions

33 practice questions for Apple Frontend Engineer interviews

Apple frontend engineer interviews emphasise JavaScript, DOM manipulation, CSS, accessibility, browser APIs, and UI component architecture.

All Roles Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer

No verified questions yet for Apple.

coding Hard caching #1

1. [OA] LRU Cache — implement a caching solution like that used for API responses in Apple Music

Apple Music optimizes data retrieval by caching previous API responses. You need to create an LRUCache to store song details, supporting efficient retrieval and updating.
Implement a class LRUCache with the following methods:
- get(key: string): string - Returns the value of the key if it exists, otherwise returns an empty string.
- put(key: string, value: string): void - Updates or adds a new key-value pair to the cache. If the cache exceeds its size, it should remove the least recently used item.
Example 1:
Input: cache.put('1', 'Song A');
Output: cache.get('1'); // returns 'Song A'
Explanation: Successfully retrieves the value stored.
Constraints:
- 1 ≤ capacity ≤ 3000.
- Keys are guaranteed to be unique.
coding Hard caching #2

2. [OA] Debounced EventEmitter — build a debounced event emitter for real-time collaboration features in Apple Notes

In Apple Notes, multiple users can collaborate in real-time. To improve performance and reduce unnecessary updates, we need a debounced EventEmitter.
Implement a class DebouncedEventEmitter that has the following methods:
- on(event: string, listener: Function): void - Registers a listener for the specified event.
- emit(event: string, data: any): void - Emits an event, invoking listeners with the provided data after a debounce interval.
- setDebounceTime(ms: number): void - Sets a new debounce time.
Example 1:
Input: new DebouncedEventEmitter().on('change', () => console.log('changed')).emit('change', { text: 'Hello' });
Output: No immediate output; 'changed' is logged after the debounce interval
Explanation: The event listener is triggered after the specified debounce time.
Constraints:
- 0 < ms ≤ 1000 for debounce time.
- 1 ≤ event listener count ≤ 100.
system design Senior api design #3

3. [OA] Client-side Router Design — design a client-side router for handling navigation in Apple TV apps

Apple TV apps require a seamless client-side routing experience to manage different screens and URLs. You need to design a router that can manage multiple routes and render components based on the current URL.
Implement a class Router with the following methods:
- registerRoute(path: string, component: Function): void - Registers a new route with its corresponding component.
- navigate(path: string): void - Navigates to the given path and renders the associated component.
Example 1:
Input: router.registerRoute('/home', HomeComponent); router.navigate('/home');
Output: HomeComponent is rendered on the screen.
Explanation: The corresponding component displays when the route matches.
Constraints:
- 1 ≤ path length ≤ 100.
- 1 ≤ component count ≤ 100.
system design Senior api design #4

4. [OA] Virtual DOM Diffing Algorithm — create a diffing algorithm for building web apps similar to Apple's Safari

Apple Safari needs an efficient way to update the UI without re-rendering the entire DOM. Your task is to design an algorithm that can diff two virtual DOM trees and return the changes needed to update the real DOM.
Implement a function diff(oldTree: Node, newTree: Node): Array<Change> where Change is an object containing the type of change and the relevant node information.
Example 1:
Input: diff(oldTree, newTree)
Output: [{ action: 'remove', node: oldNode }, { action: 'add', node: newNode }]
Explanation: Returns an array of changes needed to transform the old tree into the new tree.
Constraints:
- 1 ≤ |oldTree|, |newTree| ≤ 10^3

Related Apple Frontend Engineer interview prep

Start practicing Apple questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free