## Recent Interview Questions

- 0of 0 votes
Given a Tree where each node contains an attribute say color(R,G,B... etc). find subtree with maximum number of attributes.

Input:

G

/ \

B R

/ \ / \

B B R R

/ \ / \

B R R R

Output:

Input:

R

/ \

R R

\ / \

R R R

- 2of 2 votes
Convert a string with digits into a literal representation of the number like: 1001 to one thousand one

- 0of 0 votes
Determine whether the inorder of n binary trees is the same

- 0of 0 votes
Give you a csv file There are three columns are id, parent, weight Then give you a class Node which has these three fields

But you also have the option of adding more fields for you to print out all the node's subwebs.

The definition of subweight is the sum of the node's weight plus the subweight of his children.

- 0of 0 votes
Give a chessboard, check if a group of white chesses are surrounded by all black chesses.

- 0of 0 votes
`We encode a string, s, by performing the following sequence of actions: Replace each character with its ASCII value representation. Reverse the string. For example, the table below shows the conversion from the string "Go VMWare" to the ASCII string "711113286778797114101": // Character G o V M W a r e // ASCII Value 71 111 32 86 77 87 97 114 101 // // We then reverse the ASCII string to get the encoded string 101411797877682311117. // // For reference, the characters in s are ASCII characters within the range 10 - 126 which include special characters. // // Complete the decode function in the editor below. It has one parameter: // encoded - A reversed ASCII string denoting an encoded string s. // // The function must decode the encoded string and return the list of ways in which s can be decoded. static Collection<String> decode(String encoded) { }`

- 1of 1 vote
Imagine a computer where you have no "/" (divide) operation. All other operations are implemented including addition, multiplication, binary shift etc. Implement function div(int a, int b) using available operators only.

- 2of 2 votes
Given the list of the numbers. In this list, there are the numbers from the Fibonacci sequence.

Write the algorithm that retrieves all the numbers which belong to the Fibonacci sequence of numbers.

- 0of 0 votes
Given a list of relationship of report

A reported to D, D reported to Z, who are reported to Z

- 0of 0 votes
Give the structure of a directed graph

START -> a -> b -> c -> END

If a word can start from start and end at END, then we think the word is in this diagram

For example, the string "abc" is consistent, but "ab" does not match,

Although "ab" is also inside the graph, b's next is "c" instead of END, so it's not legal word

(Note: each node can have more than one next)

1. According to the problem, design the data structure

Write a function, input is START and a string, to determine whether the string is a valid word

3. follow up, if the graph has cycle, how to do?

4. If the graph has repeated characters how to do?

- 0of 0 votes
Javascript solution for this question???

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

- 2of 2 votes
Decompress string - string (s) followed by {n} denotes s repeating n times

"a(b(c){2}){2}d" decompresses to "abccbccd"

"((x){3}(y){2}z){2}" decompresses to "xxxyyzxxxyyz"

- 0of 0 votes
Design a system that works like the you see on Amazon search - lets say you enter 'women's sandals'. What happens in the background? Explain all that you can think of.

- 0of 0 votes
Given a Binary string of 0s and 1s, and k, Find the number of different ways to get longest continuous streak of 1s. You can flip any k number of 0s to 1s.

Example:

1)Stirng is S=1010101, K=1

Result=3

1)Stirng is S=01010, K=3

Result=1

- 1of 1 vote
Write a function that takes two numbers as strings and returns the result as a string:

mul(l string, r string) : string

Assume the numbers might be too large to be parsed into a variable of any numeric type the language has.

- -2of 2 votes
How to bring back ex lost love back with in 24 hours

- 0of 0 votes
how to check is a small matrix appear in a big matrix

boolean isSubmatrix(int[][] small, int[][] big)

- 0of 0 votes
You have to cut a wood stick into pieces. The most affordable company, The Analog Cutting Machinery,

Inc. (ACM), charges money according to the length of the stick being cut. Their procedure of work

requires that they only make one cut at a time.

It is easy to notice that different selections in the order of cutting can led to different prices. For

example, consider a stick of length 10 meters that has to be cut at 2, 4 and 7 meters from one end.

There are several choices. One can be cutting first at 2, then at 4, then at 7. This leads to a price

of 10 + 8 + 6 = 24 because the first stick was of 10 meters, the resulting of 8 and the last one of 6.

Another choice could be cutting at 4, then at 2, then at 7. This would lead to a price of 10 + 4 + 6 =

20, which is a better price.

Your boss trusts your computer abilities to find out the minimum cost for cutting a given stick.

- 0of 0 votes
Given an aray with ['a1', 'a2', .....'aN', 'b1', 'b2', ....'bN', 'c1', 'c2', .....'cN'],

stagger the subarrays so it becomes ['a1', 'b1', 'c1', 'a2', 'b2', 'c2', ...'aN', 'bN', 'cN']. The optimal solution requires linear-time

sorting and a constant space complexity.

- 0of 0 votes
How to design a spreadsheet program? How do you know to update a field after another

field was changed that it depended on?

- 0of 0 votes
Given a set of points in the 2D coordinate system, find the radius of the

smallest circle which encompasses

all the given points

- 0of 0 votes
Try to come up with a combination of two data structures to implement a

data structure that supports search,

delete in O(1) time and insert in O(n) time.Try to come up with a combination of two data structures to implement a

data structure that supports search,

delete in O(1) time and insert in O(n) time.

- 0of 0 votes
You are given an integer N,print N+1 lines in a following manner

case 1: N=3 then the pattern would be

333

313

323

333

case 2: N=4 then the pattern would be

44444

44144

44244

44344

44444

- 0of 0 votes
What is the greatest common factor of all integers of the form p^4 + 1where is a prime number greater than 5?

- 0of 0 votes
A king gathers all the men in the kingdom who are to be put to death for their crimes, but because of his mercy, he will pardon one. He gathers the men into a circle and gives the sword to one man. The man kills the man to his left, and gives the sword to the man to the dead man's left. The last man alive is pardoned.

With 5 men, the 3rd is the last man alive.

Write a program that accepts a single parameter: a number N that represents the number of criminals to start with. The program should output the number of the last two men alive.

Example #1: myProgram 5

would output:

5, 3

Example #2: myProgram 7

would output:

3, 7

- 0of 0 votes
It was asked in Chargebee off campus interview. Needed solution for this problem in java

Given a string say s and k denotes the number of commas and the output should be like when you insert the comma in the string at different places and find the maximum number.

Test case 1

say s = 999 and k = 1 so the choice would be 9,99 or 99,9 in either case the maximum number is 99

Test case 2

say s=999 and k =2 so the choice will be like 9,9,9 so output will be 9

Test case 3

say s = 857 and k = 1 the choice would be 85,7 or 8,57 so the output will be like 85

- 0of 0 votes
If you are able to find the bug in production but not in the test build, how will you test it so the bug is found in the test build?

- 0of 0 votes
/**

*

* Google OnSite Round 3

*

* Data structure for Task Dependency

* A task can start only after all its pre-requisites are done

*

* Code the methods addTask(preRequisiteTask, dependentTask)

* and

* getExecutionSequence()

*

*/

- 0of 0 votes
/**

*

* Google OnSite Round 2

*

* Input is an integer array A

* Return an array B such that B[i] = product of all elements of A except A[i]

*

*/

- 0of 0 votes
/**

*

* Google Telephonic Round 2

*

* Given any uppercase string. Report the starting index at which any valid permutation of

* ABCDEF starts. If not found, then report -1.

* Possible permutations of ABCDEF are ABCDFE, BCDAFE, FEDCAB etc (a total of 6! = 720 permutations)

*

*/