Tip 1 : Make your you are understanding the logic of any question
Tip 2 : Do not skip the brute force approach
Tip 3 : If you are confidant with your your coding skills then only read or watch the questions video and try to complete as much questions as possible.
Tip 1: Make sure your resume is updated with your best achievments and experience at top and is self explainatory.
Tip 2: Try to write small and precise information and your top skills.
This was a pre screening round with recruiter where she verified that my experience was genuine and wrote down all my experience and work in details. Then she wanted to know my interests and areas of expertise.
1) My Introducation
2) Experience details
3) Projects worked at Amazon
4) What are my areas of expertise
Tip 1: Be honest because Google actually verify your details
Tip 2: Communicate well.
Tip 3: Ask your clearifying questions
It was a 90 mins long online test.
Normal Hackerrank IDE
video and audio was on the whole time
Iterate over whole string and spilt in from "|" character.
Then check for the given conditions.
Iterate over whole string and spilt in from "|" character.
Then check for the given conditions.
This was a hard problem and follow ups were also very difficult.
for 60 mins I tried my best to explain and code
it was on normal google doc.
Interviewer was giving more complex follow ups and was trying to break me every time I got comfortable and was deeply judging my problem solving skills.
interviewer was very polite and helpful but at the same time was giving harder follow ups. He communicated with me the whole time.
This question was already given on interviewbit but I did not knew this before, thus I had to come up with a solution on the spot. It tool me 60 mins to just solve one problem.
Initialise a queue to implement BFS.
Since, initially, both the jugs are empty, insert the state {0, 0} into the queue.
Perform the following state, till the queue becomes empty:
Pop out the first element of the queue.
If the value of popped element is equal to Z, return True.
Let X_left and Y_left be the amount of water left in the jugs respectively.
Now perform the fill operation:
If the value of X_left < X, insert ({X_left, Y}) into the hashmap, since this state hasn’t been visited and some water can still be poured in the jug.
If the value of Y_left < Y, insert ({Y_left, X}) into the hashmap, since this state hasn’t been visited and some water can still be poured in the jug.
Perform the empty operation:
If the state ({0, Y_left}) isn’t visited, insert it into the hashmap, since we can empty any of the jugs.
Similarly, if the state ({X_left, 0) isn’t visited, insert it into the hashmap, since we can empty any of the jugs.
Perform the transfer of water operation:
min({X-X_left, Y}) can be poured from second jug to first jug. Therefore, in case – {X + min({X-X_left, Y}) , Y – min({X-X_left, Y}) isn’t visited, put it into hashmap.
min({X_left, Y-Y_left}) can be poured from first jug to second jug. Therefore, in case – {X_left – min({X_left, Y – X_left}) , Y + min({X_left, Y – Y_left}) isn’t visited, put it into hashmap.
Return False, since, it is not possible to measure Z litres.
This problem can easily be solved by mathematical equations but I did not knew that earlier. I had only explained the interviewer BFS approach and memoized it at the end.
This had 2 questions and both were medium-hard level. I could only solve and code first question in 30 mins and for the second question I was only able to tell the approach and did not write code.
Method 1 (Use count array)
Approach:
Create a temp array temp[] of size n with all initial values as 0.
Traverse the input array arr[], and do the following for each arr[i]
if(temp[arr[i]-1] == 0), set temp[arr[i]-1] = 1;
if(temp[arr[i]-1] == 1) output “arr[i]” //repeating number
Traverse temp[] and output ‘i+1’ corresponding to the element of array temp[] having value as 0. (This is the missing number)
Note that, we use ‘arr[i]-1’ as the corresponding element to the ‘arr[i]’ in temp[] array, as indexing in an array starts from 0 to n-1 and the input array arr[] has numbers from 1 to n.
void printTwoElements(int arr[], int size)
{
int i;
cout << "The repeating element is ";
for (i = 0; i < size; i++) {
if (arr[abs(arr[i]) - 1] > 0)
arr[abs(arr[i]) - 1] = -arr[abs(arr[i]) - 1];
else
cout << abs(arr[i]) << "\n";
}
cout << "and the missing element is ";
for (i = 0; i < size; i++) {
if (arr[i] > 0)
cout << (i + 1);
}
}
Approach: This problem can be solved by using the property of the rectangle and Hash maps. If two coordinates of a rectangle are known then the other two remaining coordinates can be easily determined. For every pair of coordinates find the other two coordinates that can form a rectangle.
Below is the implementation of the above approach.
int countRectangles(vector >& ob)
{
// Creating TreeSet containing elements
set > it;
// Inserting the pairs in the set
for (int i = 0; i < ob.size(); ++i) {
it.insert(ob[i]);
}
int ans = 0;
for (int i = 0; i < ob.size(); ++i)
{
for (int j = 0; j < ob.size(); ++j)
{
if (ob[i].first != ob[j].first
&& ob[i].second != ob[j].second)
{
// Searching the pairs in the set
if (it.count({ ob[i].first, ob[j].second })
&& it.count(
{ ob[j].first, ob[i].second }))
{
// Increase the answer
++ans;
}
}
}
}
// Return the final answer
return ans / 4;
}
This round was 45 min long
It was on Google doc
2 medium to hard level questions were asked in this round. I was only able to explain and code the first question and for the second question I only explained the approach.
The interviewer was polite and helpful throughout but I was judging my problem solving skills through out.
use hashmap to store all unique name and corresponding to that frequency of the words spoken.
iterate over the array and split chats on the basis of single space character " ".
After that iterate over the hashmap and use min heap to store k most frequent elements.
Approach:
The idea is to use Depth First Search(DFS) traversal on the given tree of N nodes to find whether the given tree can be split into K equal Connected Components or not. Following are the steps:
Start DFS Traversal with the root of the tree.
For every vertex not visited during DFS traversal, recursively call DFS for that vertex keeping the count of nodes traverse during every DFS recursive call.
If the count of nodes is equals to (N/K) then we got our one of the set of Connected Components.
If the total number of the set of Connected Components of (N/K) nodes is equal to K. Then the given graph can be split into K equals Connected Components.
#include
using namespace std;
// For checking if the graph
// can be split into K equal
// Connected Components
int flag = 0;
// DFS Traversal
int DFS(vector adj[], int k,
int i, int x)
{
// Initialise ans to 1
int ans = 1;
// Traverse the adjacency
// for vertex i
for (auto& it : adj[i]) {
if (it != k) {
ans += DFS(adj, i, it, x);
}
}
// If number of nodes is
// greater than x, then
// the tree cannot be split
if (ans > x) {
flag = 1;
return 0;
}
// Check for requirement
// of nodes
else if (ans == x) {
ans = 0;
}
return ans;
}
// A utility function to add
// an edge in an undirected
// Tree
void addEdge(vector adj[],
int u, int v)
{
adj[u].push_back(v);
adj[v].push_back(u);
}
this was a 45 min long round
it was on google meet
this was Googliness and Leadership round where interviewer wanted to check if I have character which matches their principles.
The interviewer was asking behavioural questions and in every question I had to frame a story in STAR format.
Interviewer was polite.
Tip 1: Start from your most recent position and describe what you did in that position. What were your responsibilities and project. What impact did you make etc.
Tip 2: Be honest and try to communicate well. In every sentence try to show your personality with that.
Tip 3: Also show anything you did not wrote in your resume.
Tip 1: Be honest about the question and go in deapth of the approach or challenges you faced.
Tip 2: You can exaggerate a little but make sure you have great understanding about what you are saying.
Tip 3: Interviewer might ask any follow ups so be prepared.
Tip 1: This is a trick question and do not blame anyone for this.
Tip 2: Prepare all this questions before and create stories to frame.
Tip 3: Go through previuosly asked behavioral questions and prepare 1 or 2 stories for all questions
Tip 1: In this question they were trying to find how I dive deep in problem and find solution.
Tip 2: Speak in STAR format.
Tip 3: Try to prepare few stories of your previous experience and frame them in any question which is most alligned.
Team match round.
This was a 30 mins long discussion with hiring manager for team matching.
It was on google meet.
I was told that this is going to be general discussion with manager but instead I found behavioural question for which I was not at all prepared for.
Interviewer was polite and sweet but at the same time judging all mhy answers.
Tip 1: Start from your most recent position and describe what you did in that position. What were your responsibilities and project. What impact did you make etc.
Tip 2: Be honest and try to communicate well. In every sentence try to show your personality with that.
Tip 3: Also show anything you did not wrote in your resume.
Tip 1: Be honest and tell them if you were impacted by layoffs or recession.
Tip 2: Tell them you had completed great projects for this company which had huge impact.
Tip 3: Try to be positive about the company and don't blame anyone.
Tip 1: Be prepared about principles on google and on what basis they judge.
Tip 2: Tell how you are already following principles which google follows.
Tip 3: Be honest in this round.
Tip 1: Make sure you do not say 3 BAD QUALITIES instead of AREA OF OPPORTUNITY.
Tip 2: Prepare all this before coming to interview.
Tip 3: Tell the interviewer that how you are trying to improve these areas of opportunity.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you remove whitespace from the start of a string?