Google Interview Questions
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2024-10-07Added By Anonymous
Source: Link
🧭 Experience: unknown
✅ Outcome: unknown
💰 Compensation: unknown
📍 Location: unknown
🏢 Company: Google
🎓 Education: unknown
🎁 Benefits: unknown
📅 Offer Date: unknown
I have appeared for google interview. 1 st round- screening round 2nd round - coding round they asked me this question in 2nd round Imagine you have a robot that sends status messages that humans will read in real time. The raw messages are hard to read for a human because there are often many messages produced in short periods of time. One idea to make them more readable is to remove the duplicate messages over a 10 second window. Design and implement a program to hide duplicates of any message that has already been displayed within the past 10 seconds. Example 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 it was a easy problem but i was trying to give approach only. but didn't write the code as interviewer was not okay with approach. it was a easy HashMap question where we just need to store message as key and timestamp as value. if msg is not present in hashmap return true and print the message and store the message in hashmap and then find lasttimestamp of that message in HashMap , if timestamp-lasttimestamp> threshold time then return true and print the msg and store the msg else return false and not store message. I was cleared with this, but interviwer didn't ask to write code. and may be i lost the opportunity this time. Because i didn't write code. lets see what will be result.
I have appeared for google interview. 1 st round- screening round 2nd round - coding round they asked me this question in 2nd round Imagine you have a robot that sends status messages that humans will read in real time. The raw messages are hard to read for a human because there are often many messages produced in short periods of time. One idea to make them more readable is to remove the duplicate messages over a 10 second window. Design and implement a program to hide duplicates of any message that has already been displayed within the past 10 seconds. Example 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 it was a easy problem but i was trying to give approach only. but didn't write the code as interviewer was not okay with approach. it was a easy HashMap question where we just need to store message as key and timestamp as value. if msg is not present in hashmap return true and print the message and store the message in hashmap and then find lasttimestamp of that message in HashMap , if timestamp-lasttimestamp> threshold time then return true and print the msg and store the msg else return false and not store message. I was cleared with this, but interviwer didn't ask to write code. and may be i lost the opportunity this time. Because i didn't write code. lets see what will be result.