Google Interview Question for Software Engineers


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

- aonecoding January 05, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can you explain the question with more details?

- rick January 08, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int func(int[] arr, int k) {
        int ans = Integer.MAX_VALUE;
        Deque<Integer> q = new LinkedList<>();
        int ptr = 0;
        int length = arr.length;
        while (ptr < length) {
            int ele = arr[ptr];
            if (q.isEmpty() == true) {
                q.add(ptr);
                ptr++;
            } else {
                if (ptr-q.getFirst() <= k) {                    
                    if (ele >= arr[q.getFirst()]) {
                        while (q.isEmpty() == false) {
                            q.remove();
                        }
                        q.add(ptr);
                        ptr++;
                    } else {
                        if (ele >= arr[q.getLast()]) {
                            q.removeLast();
                        } else {
                            q.add(ptr);
                            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();
                        }
                        q.add(ptr);
                        ptr++;
                    } else {
                        if (ele >= arr[q.getLast()]) {
                            q.removeLast();
                        } else {
                            q.add(ptr);
                            ptr++;
                        }
                    }
                }
            }
        }
        return ans;
    }

- Aim_Google January 09, 2018 | Flag Reply
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('=================')

- saidu March 09, 2018 | Flag Reply
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('=================')

- saidu D March 09, 2018 | Flag Reply


Add a Comment
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.

Learn More

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.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More