Apple logo

Apple Frontend Engineer Coding 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.

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