📌 Phone Screening (DSA)
🔹 Top K Frequent Words
🔹 Max Consecutive Ones
Follow-up: Return the starting & ending index of the longest consecutive ones.
📌 Round 1: Simplify Expressions
🔹 Simplify:
(a + b) − (b + c) → a − c
(a − b) − b − b → a − 3b
a + b − (c + (d − b)) → a + 2b − c − d
📌 Round 2: Cartesian Plane - Equal Area Division
🔹 Problem Statement:
Given multiple rectangles on a Cartesian plane, find a vertical line (parallel to Y-axis) such that the total area on both sides is equal.
Follow-ups:
What if rectangles can overlap?
Can this be solved efficiently?
📌 Round 3: Predict the Most Frequent Word in a Stream
🔹 Problem Statement:
Given a stream of words, predict the most frequent next word.
Must run in O(1) prediction time.
🔹 Example Input:
["I am great", "Great is me", "I am fool", "I like Running", "I like Football", "I like Singing"]
🔹 Expected Output:
If a user types "I", return "like", because "I like" appears 3 times.
🔹 Follow-ups:
How to update the frequency efficiently when new data arrives?
What if we need to predict the next 2 most frequent words?
Hope this helps! Feel free to ask any questions. 😊