Google SSE Interview

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-06-12Added By Anonymous
Source: Link

Company: Google
Role: L5/L6
Interview Stage: Onsite
Location: unknown
Year: unknown

Original Post Content:

Round 1
You are given a few APIs:

API that is responsible to calculate a callback function after relative_time_stamp_in_mills from the time of the call setCallBackHandler.
void setCallBackHandler(int relative_time_stamp_in_mills);

API that gives current system time in mills.
int getSysTime();

You have to write a method called ScheduleCallback(call_back_func_pointer, time_in_mills) that does the job of scheduling a call to call_back_func_pointer after time_in_mills from the call.

1.The calls might come in parallel.
2.setCallBackHandler can only save ONE TRIGGER AT A TIME. So if the new request is supposed to get executed first, you need to handle that gracefully.
3.setCallBackHandler takes in relative time.

Round 2
You are given a Class with two methods

Class CWFuture{
    CWFuture(Const int machine_id, const int doc_id);
    int join() // Returns the number of words in the document file. This is a blocking call, it won't return if the process is still calculating the words in the document
    int isDone() // Returns true if the calculation is done else false
}

Given max_doc_ids, you need to write a method, use CWFuture class and calculate the total number of words in doc IDs ranging from [0, max_doc_ids) and return that number.

Scenario 1: You have unlimited number of machines available.
Follow up scenario 2: What if you have at max N number of machines with you.
Scen 3: Discussion: How would you improve the accuracy of your result if the API is not accurate every time. Let's say 90% of the time it returns correct response.

Write C++ code for both scenarios separately and implement a method called CountWords.

Round 3:
You are given a data structure of HTML Content and tags. Looks like this. A node can be an html tag OR a string text.

class Node{
    bool isText();
    string getText();
    vector<Node*> getChildren();
}

You need to implement a method that takes in Head of the node and a string to search. And you should return the nodes that cover the search string within the structure.

<span><b>This</b> is a <i>funny Text.</i> </span>

The content structure can be represented as a tree:

  • Node 1 is a <span> tag, parent of Node 2, Node 4, Node 5.
  • Node 2 is a <b> tag, parent of Node 3.
  • Node 3 is text "This".
  • Node 4 is text " is a".
  • Node 5 is an <i> tag, parent of Node 6.
  • Node 6 is text " funny Text.".

Case 1: Search = "is a"
Returns Node 4

Case 2: Search "a fun"
Returns Node 4 and Node 6.

vector<Node*> GetNodes(Node* head, string& search);

Implement GetNodes.

Overall it was a reject. You'll find the answers on Chat GPT. Apparently interviewer for the first round was expecting me to use threads and mutexes and actually implement it. That's where I lost.

Comments