Google Interview Question | May-2025

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2025-05-24Added By Anonymous
Source: Link
🧭 Experience: unknown
✅ Outcome: unknown
💰 Compensation: unknown
📍 Location: unknown
🏢 Company: Google
🎓 Education: unknown
🎁 Benefits: unknown
📅 Offer Date: unknown

## Mock Interview Question1: https://leetcode.com/problems/shortest-unsorted-continuous-subarray/description/ Question 2: Imagine we are a software development company and we manage our dev process using an issue tracking tool. Each issue has an ID and also a list of IDs of issues which block it (Blockers or parents). As a result we have 1 or multiple unidirectional graphs because there could have several root issues. At some point in time someone added an issue A as a Blocker of issue B. But because A was already blocked by the descendants of the current issue B (descendants of B are the issues that are transitively blocked by B), this created a circular dependency. After this our UI issue tracking tool (Taskflow) stopped showing issues correctly. Our task is to find out all circular dependency loops. The input is a 2D boolean array of blockers assignments. The row number is the issue ID. The column number is Blocker issue ID. So entry (i, j) is True means that issue i is blocked by issue j. Example input: Where for (i,j) (0,0)=False | (0,1)=False | (0,2)=True (1,0)=True | (1,1)=False | (1,2)=False (2,0)=False | (2,1)=True | (2,2)=False The output is a list of dependency cycles. The order inside one cycle doesn't matter. Example: [ [0, 2, 1] (as well can be 2,1,0 or 1,0,2) ] ## Coding 1 You're given a log stream of a chat application. Every log entry has the following fields: timestamp: long - the number of seconds that have elapsed since 1970-01-01. sender: str - username of the sender receiver: str - username of the receiver message_text: str - the message payload We want to implement a log stream processor which supports two methods: RegisterEvent(timestamp, sender_username, receiver_username, message_text) - registers the event that the message have been sent GetMostActiveUser() - Returns the user with the largest number of active conversations. We count any amount of messages exchanged between two unique users as a single conversation. Examples: RegisterEvent(0, "A", "B", "Hi!") GetMostActiveUser() -> "A" or "B" // Both users have a single conversation. RegisterEvent(10, "A", "C", "Hi!") RegisterEvent(15, "C", "A", "Hi, there!") GetMostActiveUser() -> "A" ## Coding 2 EExample Messages Received, with Timestamps: 10 solar panel activated 11 low battery warning 12 tire one: low air pressure 13 solar panel activated 14 low battery warning 21 solar panel activated 35 solar panel activated Example Messages Shown to User: 10 solar panel activated 11 low battery warning 12 tire one: low air pressure 21 solar panel activated 35 solar panel activated //sorted timestamp //stream of data, decide best way to represent incoming data //only message in output, order in output //10 secs, requirement, within 10 de-duplciate, after that show the message //Set<String> messagesSet //List<String> messagesList // Map<String, Integer> messageToLastTimestamp = new HashMap<>(); void recieveAndSendMessage(long timestamp, String message){ if(!messageToLastTimestamp.containsKey(message) || messageToLastTimestamp.get(message) < timestamp - 10) { messageToLastTimestamp.output(message, timestamp); sendMessgae(message); return; } return; } Example Messages Received: 10 solar panel activated 11 low battery warning 12 tire one: low air pressure 14 low battery warning 21 solar panel activated => 10 solar panel ... 35 alkndfslsdnf => 12 <no more messages received for another 11 seconds> ## Coding 3 //Maps, 1) roads one way 2) city name is unique 3) no cycles //design class, starting from a given city, all the rechable cities from given city //cities = [a, b, c, d], edges: [[a,b]...] //input: "a" //output: [b,c,d] //scale: big
Comments