## Recent Interview Questions

- 0of 0 votes
A Research team want to establish a research center in a region where they found some rare-elements. They want to make it closest to all the rare-elements as close as possible so that they can reduce overall cost of research over there. It is given that all the rare-element’s location is connected by roads. It is also given that Research Center can only be build on road. Team decided to assign this task to a coder. If you feel you have that much potential..

Here is the Task :- Find the shortest of the longest distance of research center from given locations of rare-elements.

Locations are given in the matrix cell form where 1 represents roads and 0 no road..

Number of rare-element and their location was also given(number<=5)

and order of square matrix was less than equal to (20).

- 0of 0 votes
Implement a grep-like function. For example

[A1 + A2, B1 + B2, C1], grep (A = A1), is to return the result that contains A1,

For example, [A1, B1, C1], [A1, B2, C1].

More tricky can be grep (A = A1, A2, B = B1), so that is included (A1 || A2) & B1.

- 0of 0 votes
Given an array {a0, a1, a2, ... an, b0, b1, b2 ... bn},

Rearrange this array into {a0, b0, a1, b1, a2, b2, ... an, bn}

inplace, O (1) space

- 1of 1 vote
Suppose there is a map with N bikes on it and now we have N individuals,

Design an algorithm so that everyone can get the bike in the shortest distance

- 0of 0 votes
Given a string, at each time, you can move any one of the char to the front,

ask you to find the minimum such move to get the target string

example

source abc, target cba :

abc -> bac -> cba

return 2

- 0of 0 votes
Minimum Continuous Subsequence: targetList & availabletTagsList are two lists of string.

Input:

targetList = {"cat", "dog"};

availableTagsList = { "cat", "test", "dog", "get", "spain", "south" };

Output: [0, 2] //'cat' in position 0; 'dog' in position 2

Input:

targetList = {"east", "in", "south"};

availableTagsList = { "east", "test", "east", "in", "east", "get", "spain", "south" };

Output: [2, 6] //'east' in position 2; 'in' in position 3; 'south' in position 6 (east in position 4 is not outputted as it is coming after 'in')

Input:

targetList = {"east", "in", "south"};

availableTagsList = { "east", "test", "south" };

Output: [0] //'in' not present in availableTagsList

Note: targetList will contain Distinct string objects.

- 0of 0 votes
Give you a bunch of light bulbs. Can flip a range of open change off, turn off open, and then asked to do so k times later, just ask you a light bulb is turned on or turned off, how to do

- 0of 0 votes
*e*er -> peter

**eue -> queue

**o

ma*

*p*a*e*

*erso*

***k*am*on

*ouse

*a*

*ur*

***igent

where there are 26 *, and we can fill all the stars in to form valid english words while using each letter once. Given this array and a dictionary how would you fill all the words in?

- -2of 2 votes
public string stringWrap (String text, int characters)

text is an input string, characters on behalf of the output of

each line up to the number of bytes

input`"Thank you for shopping at the XYZ store.\n Your order has been processed successfully.\n", 20 output： "Thank you for\n shopping at the XYZ\n store.\n Your order has been\n processed\n Successfully.\n" example 2:"Hello! How are you?"，6 output “Hello!\n How\n are\n you?\n"`

- -3of 3 votes
Modify the following code:

`def GenerateGraph(data): d = {} g = Graph() for word in data: for i in range(len(word)): bucket = word[:i] + '_' + word[i+1:] if bucket in d: d[bucket].append(word) else: d[bucket] = [word] for v in d.keys(): for word1 in d[v]: for word2 in d[v]: if word1 != word2: g.addEdge(word1,word2) return g`

The objective is to find all combination of words by changing one letter at a time and adding to the graph if word exists in the dictionary.

We need to rewrite a different logic for the above code.

- 1of 1 vote
Give a string [] words,

Find the shortest string [] containing the keyword inside.

example:

words: sky cloud google search sky work blue

keywords: sky blue

return: sky work blue

- 1of 1 vote
Given an array, find the number of tuple such that A [i] + A [j] + A [k] = A [l] in an array, where i <j <k <l.

- 1of 1 vote
Given a n-nary tree, check whether it is a mirror of itself (ie, symmetric around its center).

class TreeNode {

int val;

List<TreeNode> children;

TreeNode(int val) {

this.val = val;

children = new ArrayList<>();

}

}

- -2of 2 votes
Imagine a scenario where there are N cars on an infinitely long single-lane road. Each car has a unique, permanent integer speed ranging between 1 and N, inclusive (units are irrelevant). The cars can be placed in any order along the road and then told to start driving indefinitely. Let's assume that the cars are traveling from right-to-left. So the leftmost car is at the front. Given an ordering of N cars, construct an algorithm to return an array of cluster sizes

N=4

[2, 4, 1, 3] -> [2, 2]

[2, 5, 4, 3, 1] -> [4, 1]

followup：

New car speed = N+1. Given an ordering of N cars, construct an algorithm to return an array of arrays of cluster sizes that will arise when the N+1 car is inserted. The ith row in the outer array corresponds to the cluster sizes that exist when the N+1 car is inserted into the ith index

new car speed = 5

[2, 4, 1, 3] -> [[1, 2, 2], [3, 2], [3, 2], [2, 3], [2, 3]]

- -1of 1 vote
Given a list of characters, write a function to output a list of length of minimum non overlapping subsequences that can partition the input list.

For example:

Input : [a,b,c]

Output: [1,1,1]

Explanation: There are no repeated characters.

Input : [a,b,c,a]

Output: [4]

Explanation: The 'a' is repeated so one subsequence is between a to last a.

Input : [a,b,c,b,a,e,b,a,d,f,g,d,f,i,f,k,l,m,n,m,l]

Output: [8,7,6]

Explanation: max length from 1st 'a' to last 'a' is 8.

1st 'f' to last is 6 adding d to it = 7

so on

- 1of 1 vote
Michelle has created a word game for her students. The word game begins with Michelle writing a string and a number, K, on the board.

The students must find a substring of size K such that there is exactly one character that is repeated one;

in other words, there should be k - 1 distinct characters in the substring.

Write an algorithm to help the students find the correct answer. If no such substring can be found, return an empty list;

if multiple such substrings exist, return all them, without repetitions. The order in which the substrings are does not matter.

Input:

The input to the function/method consists of two arguments - inputString, representing the string written by the teacher;

num an integer representing the number, K, written by the teacher on the board.

Output:

Return a list of all substrings of inputString with K characters, that have k-1 distinct character i.e.

exactly one character is repeated, or an empty list if no such substring exist in inputString.

The order in which the substrings are returned does not matter.

Constraints:

The input integer can only be greater than or equal to 0 and less than or equal to 26 (0 <= num <= 26)

The input string consists of only lowercase alphabetic characters.

Example

Input:

inputString = awaglk

num = 4

Output:

[awag]

Explanation:

The substrings are {awag, wagl, aglk}

The answer is 'awag' as it has 3 distinct characters in a string of size 4, and only one character is repeated twice.

- 0of 0 votes
Given one string s1, and then insert one char into this string at any place, to get s2, find the inserted char

Could you do it in logn time

- 0of 0 votes
There are three numbers a, b, and c. the product of any two numbers is equal to the third number. For example a*b=c or b*c=a or a*c=b. Then what are the possible a, b and c values?

- 0of 0 votes
Give you a 2xN board and two kinds of tiles: 1x2 (two squares across), 2x1 (two squares up) Ask how many ways you can fill the board.

`** ** * * * * ** **`

Follow up is the new four kinds of tiles: L shape in different angle, , ask you how many kinds of tiles are now six

- 0of 0 votes
give a binary matrix, 0 on behalf of the sea, 1 on behalf of the land, the val also represents the height of the altitude, if a cell is originally on land and is also surrounded by eight neighbor are on land, that cell become 2, each cell and its eight neighbor elevation cannot differ by more than 1. Return to the highest altitude can take altitude (special case is if the entire matrix is 1, then it is unlimited)

- 0of 0 votes
In the range of 0-n, return all the numbers that in the reverse can be mistaken for another number. E.g. 18 -> 81. The corner case is not counting the same number, such as 101 and not 0 at the end of the figure such as 60 (because 09 is not 9)

Public List<Integer> getNum(int n)

- 0of 0 votes
Hi, I am always confused what is the fundemental difference (and thereby interviewer's expectation) on a 'System Design' question vs 'Object Oriented' design question ?

For ex - In a recent interview i was asked to design a System Design for a YouTube like application.

By system design, do they expect DB Layer, Application Server level setup, server caching, how the UI layout should be etc ?

And by Object oriented design / Application design do they expect the set of Classes , Methods, Interfaces and their communication logic ?

Will be of great help if someone can clarify this basic question.

Thanks.

- 0of 0 votes
Given a function that reads 4096 bytes from a file. write a new function which takes in a buffer and the number of bytes to be read from the user and uses the given function to write values into the buffer.

//given

//returns the number of bytes read

private int read4k(int[] buffer, int offset)

//TODO:

// it should return the bytes read

public int readIntoBuffer(int[] buffer, int byteCount);

- 0of 0 votes
SYNONYM: LYNCH

A. Hang B. Madden C. Kill D. Shoot

- 0of 0 votes
Today is Monday. After 61 days, it will be:

A. Wednesday B. Saturday C. Tuesday D. Thursday

- 0of 0 votes
If x and y are the two digits of the number 653xy such that this number is divisible by 80, then x + y =?

A. 2 or 6 B. 4 C. 4 or 8 D. 8

- 0of 0 votes
The least number of complete years in which a sum of money put out at 20% compound interest will be more than doubled is:

A. 3 B. 4 C. 5 D. 6

- 0of 0 votes
The cost price of 20 articles is the same as the selling price of x articles. If the profit is 25%, then the value of x is:

A. 15 B. 16 C. 18 D. 25

- 0of 0 votes
Which one of the following is a static member of thread?

A. current thread()

B. getName()

C. join()

D. interrupt

- 0of 0 votes
The order of the top three level elements of the java source file is

A. import, package, class B. class,import,package C. package, order, class D. random order