## Google Interview Question for Software Engineers

• 3

Country: United States
Interview Type: In-Person

Comment hidden because of low score. Click to expand.
2
of 2 vote

Looking for help on interview preparation?
Visit AONECODE.COM for ONE-TO-ONE private lessons by FB, Google and Uber engineers!

Customized course covers
System Design (for candidates of FB, LinkedIn, AMZ, Google and Uber etc)
Algorithms (DP, Greedy, Graph etc. every aspect you need in a coding interview and Clean Coding)
Interview questions sorted by companies
Mock Interviews

Our members got into G, U, FB, Amazon, LinkedIn, MS and other top-tier companies after weeks of training.

Feel free to email us aonecoding@gmail.com with any questions. Thanks!

``````# The question is about identifying any window size k that its numbers at both ends bigger than numbers in between
def bloomDay(a, k): # k must be >= 0
window = [] # elements in window maintain descending order.
firstDay = 10000000
i = 0
while i < len(a):
if not window:
window.append(i)
i += 1
elif i - window[0] <= k:
if a[i] >= a[window[0]]:
window = [i]
i += 1
elif a[i] >= a[window[-1]]:
window.pop()
else:
window.append(i)
i += 1
else: #window size == k
if len(window) == 1 or a[window[1]] < a[i]:#valid window with both end numbers biggest
firstDay = min(firstDay, a[i], a[window[0]])
window = [i]
i += 1
else:  #a[i] is less than a number in the middle of the window
window.pop(0)
if a[window[-1]] <= a[i]:
window.pop()
else:
window.append(i)
i += 1
return firstDay``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

Can you explain the question with more details?

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````int func(int[] arr, int k) {
int ans = Integer.MAX_VALUE;
int ptr = 0;
int length = arr.length;
while (ptr < length) {
int ele = arr[ptr];
if (q.isEmpty() == true) {
ptr++;
} else {
if (ptr-q.getFirst() <= k) {
if (ele >= arr[q.getFirst()]) {
while (q.isEmpty() == false) {
q.remove();
}
ptr++;
} else {
if (ele >= arr[q.getLast()]) {
q.removeLast();
} else {
ptr++;
}
}
} else {
int x = arr[q.removeFirst()];
if (ele > arr[q.removeFirst()]) {
ans = Math.min(ans, Math.min(ele, x));
while (q.isEmpty() == false) {
q.remove();
}
ptr++;
} else {
if (ele >= arr[q.getLast()]) {
q.removeLast();
} else {
ptr++;
}
}
}
}
}
return ans;
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````import re
fl = [9,5,1,8,2,6,4,3,7]
l = [0]*(len(fl))
l = list(map(str,l))
k=2

for i in fl:
l[i-1]='1'
print(''.join(l),i)
ll = re.finditer(r'1(0)+1',''.join(l))
lll = [i.group(0)[1:-1] if ll else print('hi') for i in ll]
#print(list(lll))
lens=[]
for j in list(lll):
lens.append(len(j))
#print('lengths---> ',lens)
if any(t==k for t in lens):
print('FOUND')
print('day is: ',fl.index(i))
break
print('=================')``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````import re
fl = [9,5,1,8,2,6,4,3,7]
l = [0]*(len(fl))
l = list(map(str,l))
k=2

for i in fl:
l[i-1]='1'
print(''.join(l),i)
ll = re.finditer(r'1(0)+1',''.join(l))
lll = [i.group(0)[1:-1] if ll else print('hi') for i in ll]
#print(list(lll))
lens=[]
for j in list(lll):
lens.append(len(j))
#print('lengths---> ',lens)
if any(t==k for t in lens):
print('FOUND')
print('day is: ',fl.index(i))
break
print('=================')``````

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.