Meta Interview Questions
- DSA
- LLD
- HLD
Q1: Move Zeros to the Left
Given an integer array, move all elements that are 0 to the left while maintaining the order of other elements in the array. The modification must be in-place, with no additional memory allocated for a new array. This evaluates in-place manipulation and two-pointer concepts.
Example:
Input: array: [1][0][2][0][3][4]
Output: [0][0][1][2][3][4]
Explanation: Traverse the array from right to left, swapping zeros with non-zero elements to shift all zeros to the left while retaining the original order of non-zero numbers.
Q2: Return the Level Order Traversal of a Binary Tree
Given the root of a binary tree, return its level order traversal (values from left to right, level by level). This checks BFS traversal skills and understanding of tree data structures.
Example:
Input: tree: [3, 9, 20, null, null, 15, 7]
Output: [[3], [9][20], [15][7]]
Explanation: Use a queue to process nodes level by level: enqueue root, dequeue and enqueue children in order, forming a list for each level.
Q3: Subarray Sum Equals K
Given an array of integers and an integer k, find the total number of continuous subarrays whose sum equals to k. Efficient solution involves prefix sums and hash maps.
Example:
Input: nums: [1][2][3], k: 3
Output: 2
Explanation: The subarrays [1][2] and [3] have sum equal to k.
Q4: Maximum Size Subarray Sum Equals k
Find the maximum length of a subarray that sums to k in an integer array. Tests prefix sum optimizations and hashmap usage.
Example:
Input: nums: [1, -1, 5, -2, 3], k: 3
Output: 4
Explanation: The longest subarray [1, -1, 5, -2] sums to 3.
Q5: Minimum Window Substring
Given two strings s and t, return the minimum window substring of s that contains all the characters in t. Classic sliding window and hashmap interview test.
Example:
Input: s: “ADOBECODEBANC”, t: “ABC”
Output: “BANC”
Explanation: The substring “BANC” is the minimum-length window in s that contains all characters of t.
Q6: Rotate Array Problem
Rotate elements of an array by k steps.
Example:
Input: nums: [1][2][3][4][5][6][7], k: 3
Output: [5][6][7][1][2][3]
Explanation: Array is rotated right by 3 steps.
Q7: Serialize and Deserialize Binary Tree
Convert tree to string and back (serialization/deserialization). Focus: recursion, DFS.
Example:
Input: Tree: [1,2,3,null,null,4,5]
Output: Serialized: “1,2,null,null,3,4,null,null,5,null,null”
Explanation: Preorder traversal, null for missing children.
Deserialize reconstructs the original tree.
Q7: Add Two Numbers (Linked List)
Add two numbers represented by linked lists; each node contains a single digit.
Example:
Input: l1: [2][4][3], l2: [5][6]
Output: [7][0][8]
Explanation: 342 + 465 = 807; result stored in reverse order.
Q1. Design a TinyURL Service
Design a system that encodes long URLs into short, unique URLs and decodes them back. System should guarantee uniqueness and high performance. Core concepts: hash tables, random string generation, collision avoidance.
Example:
Input: long_url: “https://www.facebook.com/“
Output: short_url: “http://tiny.url/abcd1234“
Explanation: Generates a short URL “abcd1234” mapped to the original URL for future decoding.
Q2. LRU Cache (Production-Ready)
Design and implement an LRU (Least Recently Used) cache as a reusable library. It should be thread-safe, efficient, and scalable for real-world applications.
Q3. Design a Messenger Chat System
Implement a chat system backend for one-on-one and group messaging, supporting message storage, delivery guarantees, read receipts, and history. Key focus: scalability and reliability, conversation data structures, notification logic.
Example:
Input: sendMessage(“alice”, “bob”, “Hi Bob!”)
Output: Message delivered, status: sent
Explanation: Stores message in chat history, triggers notifications, and handles delivery status.
Q4. Implement LRU Cache Class
Implement a Least Recently Used (LRU) cache supporting get and put operations in O(1) time using a double linked list and dictionary. Core data structure and algorithm fidelity are tested.
Example:
Input: put(1,1), put(2,2), get(1), put(3,3), get(2)
Output: [1, -1]
Explanation: After putting (1,1) and (2,2), get(1) returns 1; put(3,3) evicts key 2; get(2) returns -1.
Q1. News Feed System Design
Design a scalable news feed system that aggregates and displays posts from friends and relevant pages. Focus is on feed generation, ranking, caching, and real-time update mechanisms.
Example:
Input: UserA posts “Hello!”, UserB posts “Welcome!”
Output: News feed: [“Welcome!”, “Hello!”]
Explanation: Feed shows sorted posts by timestamp and relevance.
Q2. Messenger System Design (Scalable)
Architect a scalable messaging platform that supports millions of users, ensuring message delivery, persistence, horizontal scalability, and notifications. Key focus: microservices, event-driven communication, and scalability.
Example:
Input: Message sent to group with 10,000 users
Output: Message reaches all recipients, acknowledged
Explanation: System applies event queueing, reliable broadcast, and storage of conversation history.
Q3. Facebook Timeline System Design
Design a timeline system showing posts, likes, comments, and shares, optimized for fast retrieval and update. Core ideas: denormalized data storage, sharding, and efficient query patterns.
Example:
Input: Alice likes a post; Bob comments; Carol shares
Output: Timeline updates with new interactions in real time
Explanation: Update mechanisms ensure new likes, comments, and shares are promptly reflected and visible to all viewers.
Q4. E-commerce Product Catalog
Design a product catalog system with efficient search, filtering, and sorting capabilities. Handle millions of products with scalability and quick retrieval.