Position: Test Engineer [Automation]
Location: US (which later got changed to Bangalore)
Process took: 4 months
I applied through Google career portal in March and got mail from HR in a week. He asked me to schedule a call to start the interview process. Below is the detailed experience of every round.
HR phone screen:
In this call, the recruiter discussed the job description in detail and what is to be expected ahead. He asked me a few technical questions related to coding and testing (fyi, python is my main language).
Towards the end, HR asked me to schedule my technical telephonic round in next 4-5 weeks as per my convenience.
Technical phone screen:
Write a function to return local time by taking city name as input. If input is California, then function should returns its local time in Hours:Minutes:Seconds format. Write test cases for it. How would you write automation test for this function.
Below is the code, which might need some improvements. But worked for the interview.
from datetime import datetime
def get_gmt_time(city):
now = datetime.utcnow()
print(now) #returns GMT time, like 2019-04-23 09:11:44.375078
try:
diff = gmt.getOffset(city) #returns number of hours of offset for that city
except:
raise('Exception raised by API')
dt = datetime.timedelta(diff, time=hours)
return dt.hours,dt.minutes,dt.seconds,dt.millisecondsFollow-up: how would I create automation test for this function. The solution was to make sure the test runs sharp at 9 AM IST (for eg.) and returns the expected answer everytime.
Onsite:
Round 1:
Round 2:
https://leetcode.com/problems/shortest-path-in-binary-matrix
def shortestPathBinaryMatrix(self, grid: List[List[int]]) -> int:
n = len(grid)
if grid[0][0] == 1 or grid[n-1][n-1] == 1:
return -1
x_diff = [-1, -1, -1, 0, 0, 1, 1, 1]
y_diff = [-1, 0, 1, -1, 1, -1, 0, 1]
queue = collections.deque()
queue.append([0, 0, 1])
while queue:
i, j, length = queue.popleft()
if (i, j) == (n-1, n-1):
return length
l = ((i-1,j-1),(i-1,j),(i-1,j+1),(i,j-1),(i,j+1),(i+1,j-1),(i+1,j),(i+1,j+1))
for i, j in l:
if 0 <= i < n and 0 <= j < n and grid[i][j] == 0:
queue.append([i, j, length+1])
grid[i][j] = 1
return -1Round 3:
I could not solve this problem in one pass as asked by interview. Nevertheless, posting the solution after searching online:
from collections import deque
def decodestring_easy(mystr):
i = 0
stack = []
while i < len(mystr):
c = mystr[i]
if c== '[':
stack.append(c)
elif c == ']':
temp = ""
while(stack[len(stack)-1]!='['):
temp = stack.pop() + temp
stack.pop()
stack.append(temp)
elif c == '{':
num = 0
i += 1
while i<len(mystr) and mystr[i] != '}':
num = num*10 + int(mystr[i])
i += 1
pre = stack.pop()
temp = ""
while num!=0:
temp = temp + pre
num -= 1
stack.append(temp)
# print(temp)
else:
stack.append(c)
i += 1
res_str = ""
while len(stack)!=0:
res_str = stack.pop() + res_str
return res_strRound 4:
How to test a class StopWatch which measures elapsed time:
class StopWatch {
private long startTime;
private long endTime;
public void start() {
startTime = System.nanoTime();
}
public void stop() {
endTime = System.nanoTime();
}
public long elapseTime() {
return endTime-startTime;
}
}Write a function which takes a square matrix and zeroes out its both diagonals.
def operate(a):
n = len(a)
rows,cols = 0,0
while cols<=n-1:
a[rows][cols]=0
rows+=1
cols+=1
rows,cols=0,n-1
while cols>=0:
a[rows][cols]=0
cols-=1
rows+=1Round 5:
Write a function to find the 3rd largest number in a list of numbers https://leetcode.com/problems/kth-largest-element-in-an-array
My approach was to sort the list using merge sort and return third element.
def pick_third_largest(A):
n = len(A)
if n<3:
return None
mergeSort(A)
return A[2]
def mergeSort(A):
n = len(A)
if n>1:
mid = n//2
L = A[:mid]
R = A[mid:]
mergeSort(L)
mergeSort(R)
i=j=k=0
while i<len(L) and j<len(R):
if L[i] > R[j]:
A[k]=L[i]
i+=1
k+=1
else:
A[k]=R[j]
j+=1
k+=1
while i<len(L):
A[k]=L[i]
i+=1
k+=1
while j<len(R):
A[k]=R[j]
j+=1
k+=1Given a log file of following format, lines can be in any order or mixed up:
Login 1: John Smith
Login Success: 2
Login 3: User123
Login Failed: 3
Login 2: Adam Apple
Login Failed: 1Print out list of successful and failed logins:
Success:
Adam Apple
Failed:
User123
John SmithMy approach was to parse each line in log file and maintain a hash table (dictionary) having user IDs and their corresponding names. Then, print out success and failures based on the names.
dict_users=dict()
success_list=[]
failures_list=[]
with open("log.txt") as f:
mylist = f.read().splitlines()
for line in mylist:
first,last = line.split(":")
userId_or_status= first.split(" ")[-1].strip()
if userId_or_status.isdigit():
dict_users[userId_or_status] = last.strip()
else:
if first.find("Success")!=-1:
success_list.append(last.strip())
if first.find("Failed")!=-1:
failures_list.append(last.strip())
print("Success:")
for user in success_list:
print(dict_users[user])
print("Failed:")
for user in failures_list:
print(dict_users[user])
Let me know if you have any alternative solutions for the problems. Would love to hear it.