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.