## Recent Interview Questions

- 0of 0 votes

Answerscode Bubble sort, and modify it to return if the array is already sorted.

- reshma.dhotre November 30, 2018 in India

2.If single swap is needed perform and break without going through o(n2) looping| Report Duplicate | Flag | PURGE

Bloomberg LP Senior Software Development Engineer Algorithm - 0of 0 votes

AnswerIn a hashtable you can only ask for the most recent value for a key. We are going to build a hashtable where you can ask for a key at any time in the past.

- SwampNight November 29, 2018 in United States

API is:

get(k, t) // get the value for k at time t

put(k, v) // insert k, v at time()

time is given as a monotonically increasing version of unix system time.| Report Duplicate | Flag | PURGE

Software Engineer / Developer Algorithm - 0of 0 votes

AnswersIn this assignment, you will work on regular expression. For simplicity, we will assume that there is a fixed set of regular expressions. We will not consider out of these. But you must not use any built-in method or package in your implementation. If you need any method, you will write that.In Regular Expression (RE), '*' means occurrence of zero of more characters, '+' indicates happening of one or more characters, '?' means only once or not at all occurrence, '[ ]' indicates happening of inclusive characters, '^' indicates that next characters will not be used in the pattern, '[a-d]{3}' indicates that valid string will be exactly of length 3 inclusively using a, b, c, d. The following table contains a fixed set of RE that will be used in our assignment.

- amitbuetcse09 November 28, 2018 in United States

User will be asked first to input an integer value n followed by n lines of regular expressions. Then user will be asked to input another integer value m followed by m lines of text string. Your job is to say 'YES' with index of RE if the text string is valid according to any of given regular expressions. Otherwise, say 'NO' with zero index. I repeat, you must not use any built-in regular expression method or package.But you can take help from Cloud.

Input:

2

ab*c*d

a*b(cd)+e?f

3

acccd

abbbbbcccc

bcdcdef

Output:

YES, 1

NO, 0

YES, 2

Input:

3

[a-c]{3}cab+(da)*f

db*a[^def]{2}gh

def[k-p]*p+

5

defkmnpmpp

acbcabbf

pqrstdd

dbaabggh

dbbbbamkgh

Output:

YES, 3

YES, 1

NO, 0

NO, 0

YES, 2| Report Duplicate | Flag | PURGE

- 2of 2 votes

Answers[Google On-site 2018 Winter]

- aonecoding4 November 28, 2018 in United States

Set Matrix Zeroes II

There are orbs on an NxM board ('O' denotes orb. 'X' denotes empty slot).

Whenever two orbs are in the same column or the same row, you get to erase one of them.

Try to erase as many orbs as possible.

Find the minimum number of orbs remained on board eventually.

e.g.

OXOXXO

XXXXXO

XXXXOX

erase (0,0) and get

XXOXXO

XXXXXO

XXXXOX

erase (2,0) and get

XXXXXO

XXXXXO

XXXXOX

erase (5,0) and get

XXXXXX

XXXXXO

XXXXOX

no more moves available. Return 2 e.g.

OXOXXO

XXXXXO

XXOXOX

erase(4,2), (2,2), (0,0), (2,0), (5,0)

Return 1

e.g.

OXOXXX

XOXXXO

XXXOOX

erase(0,0), (1,1), (3,2)

Return 3

Follow-up Build a solver for this board game that erases the as many orbs as possible.| Report Duplicate | Flag | PURGE

Google Software Engineer - 0of 0 votes

AnswersGiven a string S of length N. Now, you need to cut the string S into K+1 non-empty substrings by performing K cuts.

- Jatin November 25, 2018 in India for 3

There are lots of ways of performing the cuts in the string S. For every way of performing the cuts, you need to count how many substrings will be a palindrome in that way of cut. You need to sum this count over all possible ways of cutting the string S. Input Format

The first line contains two integers N and K as input. The second line contains the string S as input. Output Format

In the output, you need to print the sum modulo

10^9+7. Constraints

2≤N≤5000

1≤K≤N−1

String S contains only lowercase english alphabets

Sample Input

5 2

aabbc

Sample Output

12

Explanation

In the given test case there are

6 ways to perform the cuts. All the ways are described below.

a | a | bbc = 2 substrings are palindrome

a | ab | bc = 1 substring is palindrome

a | abb | c = 2 substrings are palindrome

aa | b | bc = 2 substrings are palindrome

aa | bb | c = 3 substrings are palindrome

aab | b | c = 2 substrings are palindrome

So, the output is

2+1+2+2+3+2=12| Report Duplicate | Flag | PURGE

Backend Developer Algorithm - 0of 0 votes

AnswersThere are N nodes in a graph connected by exactly N-1 edges. There is exactly 1 shortest path from one node to any other node. The nodes are numbered from 1 to N. Given Q queries which tell source node and the destination nodes. Find the most visited node after traveling those Q paths. For example, say Q=3

- sudhiammula November 23, 2018 in India

and 3 queries are

1 5

2 4

3 1

So travel from node 1 to node 5, then from node 2 to node 4, then from node 3 to node 1. Finally, find what is the most visited node after the Q queries.

Finding every path and incrementing every visited node count is a naive solution. The interviewer asked me to optimize it.| Report Duplicate | Flag | PURGE

Samsung SDE1 Trees and Graphs - 0of 0 votes

AnswerGuys,

- zuhaibaliraja November 23, 2018 in United States

I have an interview in Google exactly after 2 weeks for software engineer position. I recently have done my MS in Information Science and I applied in google. They shortlisted my profile and sent me sample code exam which I have passed. Now it's my technical interview and I am very beginner into programming. Can please anyone help me what type of questions do they ask and how to tackle those questions. I am not good in data structures and algorithm. I self-taught programming online classes. I am so scared to face the interview. Please suggest me something| Report Duplicate | Flag | PURGE

xyz Jr. Software Engineer .Net/C - 1of 1 vote

Answers`Int minSemsToFinishAllCourses(Map<string, list<string>)`

Given a map containing courses and the list of prerequisites for that course in no particular order, determine the least number of semesters to finish all the courses.

- stevejabs November 22, 2018 in United States

You have to take all prerequisites before you take a given course.

Eg.

Calculus : English, math2

Math2: math 1, Arabic, english

Math1: english

English: <>

Arabic:<>

Give an algorithm for the above and code using java| Report Duplicate | Flag | PURGE

Algorithm Java - 0of 0 votes

AnswerRoulette -Gamblers Fallacy. start with $50, bet opposite color every time same color 4 in a row. loop 100 time or until $0. Suggest create roulette wheel object with history, a gambler object with maybe gamblingplan object. (you can find more detailed suggestions elsewhere)

- whoknows November 18, 2018 in United States| Report Duplicate | Flag | PURGE

Google SDE1 Algorithm - 1of 1 vote

AnswersGiven a tree with n nodes. Each node has k coins, where 0 <= k <= n . There are total n coins on the tree.

- aonecoding4 November 18, 2018 in United States

The goal is to move the coins such that each node has exactly one coin. What's the minimum moves required?

Each move can only move one coin to an adjacent node.| Report Duplicate | Flag | PURGE

Google Software Engineer - 1of 1 vote

AnswersAdd two numbers represented as LinkedList (not LeetCode 445 which uses ListNode)

- KelvinLong8897 November 17, 2018 in United States

e.g

inputs: '5'->'6'->'3'

'8'->'4'->'2'

output: '1'->'4'->'0'->'5'

method signature:

LinkedList<Integer> sumList(LinkedList<Integer> l1, LinkedList<Integer> l2)| Report Duplicate | Flag | PURGE

Facebook Android Engineer Algorithm - 1of 1 vote

AnswersYou have two sorted arrays, where each element is an interval. Now, merge the two array, overlapping intervals can be merged as a single one.

- Seetha November 11, 2018 in United States

I/P :

List 1 [1,2] , [3,9]

List 2 [4,5], [8, 10], [11,12]

O/P [1,2], [3,10], [11,12]| Report Duplicate | Flag | PURGE

Facebook Software Developer - 0of 0 votes

AnswersI/P [8, 3, 2, [5, 6, [9]], 6]

- Seetha November 11, 2018 in United States

O/P 8+3+2+2*(5+6+3*(9))+6 => 95| Report Duplicate | Flag | PURGE

Facebook Software Developer Arrays - 0of 0 votes

AnswersWe woild like to encourage passegers to experience the joy of travel using our transit system, therefore we would like to determine the longest path available to advertise the public. Specifically we would like to determine the longest possible trip on the transit sytem that will involve TWO tickets. The destinations must be connected, and all destinations must be unique.

- NoobieCoder3 November 10, 2018 in United States for Python development

You will be provided input in the format of CHI:NYC:719 where CHI is one location, NYC is a connected locatoion and 719 is the distance between the locations.

one line of output should be provided per line of input in the format of 3167:CHI:NYC:LA where 3167 is the distance of the trip, CHI is the starting, NYC is the intermediary location and LA is the final location.

sequence-------input---------------------------output

1------------------CHI:NYC:719----------------NONE

2------------------NYC:LA:2414----------------3133:CHI:NYC:LA

3------------------NYC:SEATTLE:2448------4862:LA:NYC:SEATTLE

4------------------NYC:HAWAII:4924---------7372:HAWAII:NYC:SEATTLE

Note: the start and end cities are lexicographical sorted.| Report Duplicate | Flag | PURGE

Jr. Software Engineer Python - 0of 0 votes

AnswerDesign and implement following . Suppose have 10 resources and 5 threads how do you design so that threads asking for

- pgopan.hai November 10, 2018 in United States

Resources should be done in order. Eg t1 asks for 3 resources, t2 asks for 4 resources…| Report Duplicate | Flag | PURGE

Cadence Inc Principal Software Engineer Threads - 0of 0 votes

AnswerGiven k,n,m. where k is no. of coconuts you initially have. n is the some no. such that if you have >=n coconuts, you becomes stressed otherwise you become normal. m is the no. of shops.You go from 1st shop to m-th shop without skipping any shop. At i-th shop, either you buy Si coconuts or sell Si coconuts. If you are stressed then you must become normal at next shop. If you have less than Si coconuts and you want to sell then you must sell all the coconuts you have. The task is to calculate maximum possible changes of your mood from stressed to normal or vice-versa.

- mendela4cazz November 09, 2018 in India

ie: shop ={100,200,100,1,1} , k=1900 , n=2100 then answer should be 3 as initially mood is happy at first shop we buy 100 coco and total are 2000<n so still happy, at shop 2 coco 2200,now mood is stressed and so| Report Duplicate | Flag | PURGE

Adobe SDE1 - 1of 1 vote

Answersfind all numbers the sum of cube of each digits is the number itself

- Aamir November 09, 2018 in United States

ex:153=1^3+5^3+3^3| Report Duplicate | Flag | PURGE

Facebook Software Engineer Intern - 0of 0 votes

Answerswhat is default pakg in java

- sajidaliit36 November 08, 2018 in United States| Report Duplicate | Flag | PURGE

Nisum Technologies Java Developer - 0of 0 votes

Answersany one can tell what is special modifers in java.

- sajidaliit36 November 08, 2018 in United States| Report Duplicate | Flag | PURGE

Nisum Technologies Java Developer - 0of 0 votes

Answers#include <iostream>

- Rising star November 07, 2018 in India

#define INF 99999

using namespace std;

int calculate(int x,int y)

{

if(x == 1) return y-1;

if(x == y||x == 0||y == 0)

return INF;

return y/x + calculate(y%x,x);

}

int minimum(int N)

{

int minmoves = N-1;

for(int i=2;i<N;i++)

minmoves = min(minmoves,calculate(i,N));

cout<<minmoves<<endl;

}

int main()

{

int N = 1;

cout <<minimum(N);

return 0;

}

Why my code showing correct output with some big integer

Like: 0

1009665443| Report Duplicate | Flag | PURGE

- 1of 1 vote

AnswersGiven a number N, Assume a lexicographical ordered 1 to N numbers.

- keviIma November 06, 2018 in United States

Given array consisting of indices, return the array with numbers at that positions in the lexicographically sorted array of [1 to N].

follow up: Do not use Extra memory.

Expected Runtime = O( N * log k) or O(N)

N = total numbers, (1 to N)

k = Number of queries

Example:

N = 12

lexicographical ordered array = [1,10,11,12,2,3,4,5,6,7,8,9]

Query = [1 , 4]

return = [10, 2]| Report Duplicate | Flag | PURGE

- 1of 1 vote

AnswerThere are A cities numbered from 1 to A.

- keviIma November 06, 2018 in United States

You have already visited M cities, the indices of which are given in an array B of M integers. If a city with index i is visited, you can visit either the city with index i-1 (i >= 2) or the city with index i+1 (i < A) if they are not already visited. Eg: if N = 5 and array M consists of [3, 4], then in the first level of moves, you can either visit 2 or 5. You keep visiting cities in this fashion until all the cities are not visited.

Find the number of ways in which you can visit all the cities modulo 10^9+7

N = 5

Visited = [2, 5]

Number of ways = 6

1 -> 3 -> 4

1 -> 4 -> 3

3 -> 4 -> 1

4 -> 3-> 1

3 -> 1 -> 4

4 -> 1 -> 3| Report Duplicate | Flag | PURGE

- 0of 0 votes

AnswersProgram to find the rank student

- Rising star November 05, 2018 in United States| Report Duplicate | Flag | PURGE

unknown freshers Algorithm - 0of 0 votes

Answers1. Input string s. Check if string s is a valid string with valid brackets

- donkeysnore November 05, 2018 in United States

For example:

(({{}})) is a valid s

{[]} is a valid s

[{[}]] is not valid

2. What kind of tests would you conduct to your program to minimize bugs in your program.

3. On the previous example there is only "()", "{}", and "[]" combination of brackets. If other developers want to add a new kind of brackets such as "<>". What kind of changes would change in your previous program.| Report Duplicate | Flag | PURGE

Bloomberg LP Intern Algorithm - 2of 2 votes

AnswersYou have N toffee packets, each containing different number of toffees. The number of toffees contained in the ith packet is denoted by ci. You need to put these toffee packets in 5 boxes such that each box contains at least one toffee packet, and the maximum number of toffees in a box is minimum.

- parni November 01, 2018 in United States

You can only choose consecutive toffee packets to put in a box.| Report Duplicate | Flag | PURGE

Google - 0of 0 votes

AnswersThe difference between move and forward in C++

- parni November 01, 2018 in United States| Report Duplicate | Flag | PURGE

Google C++ - 0of 0 votes

AnswersWe need to declare variable types in C++.

- parni November 01, 2018 in United States

How does this type declaration change the structure of the code comparing to other languages without type declaration like Python?| Report Duplicate | Flag | PURGE

JP Morgan - 0of 0 votes

AnswersGiven a matrix of 0's and 1's find the smallest number of groups made of 1's, where one group can cover up to two 1's at the same time vertically or horizontally.

- matk100.100 October 31, 2018

01111

11011

00100

The matrix above has 5 of such groups. I've seen similar questions but there the question was about groups of adjacent 1's. Here the groups are limited.

Another question how it would change, if the group wasn't limited to two but to given k - number of 1's vertically or horizontally. The time complexity should be the most efficient.

My idea here i to iterate through rows and when we find a 1, check it's bottom and right neighbour. If it has a right but no bottom, a group is made and we skip the right neighbour as it is already in a group. When the checked 1 has a bottom but no right, we make a group of them and we can skip checking the right as well i think.| Report Duplicate | Flag | PURGE

Algorithm - 0of 0 votes

AnswersPuzzle:

- valipevsr October 30, 2018 in United States

There are 4 similar bottles ,all bottles are filled with milk. In one of the bottle is poisoned. There are 4 rats with you .how many rats are required to find out poisoned bottle?| Report Duplicate | Flag | PURGE

- 0of 0 votes

AnswersThere are 4 similar bottles ,all bottles are filled with milk. In one of the bottle is poisoned. There are 4 rats with you .how many rats are required to find out poisoned bottle?

- valipevsr October 30, 2018 in United States| Report Duplicate | Flag | PURGE

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window