## Recent Interview Questions

- 1of 1 vote
Lets say someone accidentally deleted all the whitespaces from a sentence. Write a program to reconstruct the sentence from that stripped out string. Assume you have access to a dictionary function that returns if a given string is a valid word or not.

Example input: thisisavalidsentence

Output: this is a valid sentence

If multiple solutions are possible, any one valid solution should be given. Assume there is always a valid solution. No invalid input will be given.

- 0of 0 votes
Given a BST and a number n, find two numbers in the tree that sums up to n. This was to be done in place i.e. without any extra space.

- 0of 0 votes
Return the sum of all the leaf nodes at minimum level in a binary tree. If there exists no tree, then return -1.

- 0of 0 votes
given a sorted array in ascending order arrange the elements of array in such a way that largest element is at first position and second largest element at last position third largest at second position and fourth largest at last second position and so on.try to do it without any extra space.

- 0of 0 votes
Ideal goal:

Given data set of strings divide them into equivalence classes such that the equivalence relation is fuzzyMatchingOfString

Problem: as far as I know there isn’t a relation function fuzzyMatchingOfString such that it is transitive, i.e. given A,B,C and fuzzyMatchingOfString(A,B), fuzzyMatchingOfString(B,C) does not imply fuzzyMatchingOfString(A,C)

e.g. foo ~ goo and goo~gol but not foo~gol

given that I think we have to compromise about our goal and create a set to each string In our data set – that is n^2 for each run when the basic action is fuzzyMatchingOfString

- 0of 0 votes
Mickey got an assignment from his school that he has to collect money from each house for next day's event. The city is built just like a 2-D array and each house owner kept certain amount for Mickey (for ex: The house owner at (i,j) coordinate kept A[i,j] for Mickey). Mickey is in a hurry and he wants to reach home as soon as possible otherwise he will miss the match between India and Bangladesh. Also he can only move to any adjacent house from his location, and he cannot move diagonally. So please find a way so that he will collect maximum amount from everyone if he will reach home earliest.

*Input Specification*

input1 = first input will tell you size of the array

input2 = String as shown in the example and you have to parse it to build your 2-D array

*Output Specification*

output1 = You need to set maximum amount collected to this global variable (type int)

*Example*

Consider input1 = 4 and it means school is at (0,0) and his house is at (4,4). In between the houses are like input2 = '(1,7,5,2),(5,12,3,6),(100,9,23,16),(16,4,5,9)'.

To collect maximum amount, Mickey should take his path {1,5,100,9,23,16,9} so that the total amount collected,`output1 = 1 + 5 + 100 + 9 + 23 + 16 + 9 = 163`

**CLARIFICATION **

The programming test was like this, you store the input into the variables`input1`

and

`input2`

and store the output to the variable

`output1`

- 0of 0 votes
Given a multi-dimensional array as input which consists of 0's and 1's. Traverse from starting {0,0} to end {n,n} in a shortest path with any direction. You have to move to next item only when next item is 1, if it is 0, you can't move.

- 0of 0 votes
Given a undirected graph with weights, return the sum of the weight of each path between two nodes (shortest path between two vertices). Assume there are no cycles.

Example:`Input: A | 1 B 2 / \ 3 C D Output: 18 since A to B has weight 1 A to C has weight 3 A to D has weight 4 B to C has weight 2 B to D has weight 3 C to D has weight 5`

Edit: Thanks, wangchenClark0512, forgot about C to D

Edit2: @Lukas, The question is just the sum of the shortest paths between two vertices. Also, all edges are positive.

Edit3: Assume the graph has no cycles, did not get to the follow-up, but follow-up probably is probably change your algorithm so that is works for cycles

- -6of 6 votes
Facebook Customer Support | Call @ 1-844-305-0563

- -5of 5 votes
interview would be easy. For freshers it would be okay

for experienced no salary hike is available

- 0of 0 votes
Design a deck of cards that can be used for different card game applications.

Please code out what you would need for the deck class and a card class.

Implement a deal method.

- 0of 0 votes
Given two numbers M and N, P is from [M,N] and Q is from [1,P-1]. Find all irreducible fraction of P/Q.

- 0of 2 votes
pair programming example question with code for thoughworks interview

- -1of 1 vote
Design unix file system in database.

- 0of 0 votes
You are given an integer N. Write a code to calculate 1! - 2! + 3! ... up to N terms.

- 0of 0 votes
You are given a function F6() which return 1,2,3,4,5,6 randomly with equal probability. Implement a new function F12() which returns 1 to 12 randomly with equal probability using F6().

- 0of 0 votes
Suggest a data structure and implement efficient phrase search along with word search in a huge chunk of text.

- -3of 3 votes
New technologies will cause end of JAVA, Is it right or wrong? And why reason.?

- 0of 0 votes
* Given an unsorted integer array, place all zeros to the end of the array without changing the sequence of non-zero

* elements. (i.e. [1,3,0,8,12, 0, 4, 0,7] --> [1,3,8,12,4,7,0,0,0])

- 0of 0 votes
* Implement a tick server the has multiple clients interested in different tickers. Clients have Plotters that are updated

* in real-time with the top 10 tickers that have the most price updates on the top. What data structure would you choose

* for the server and client plotters?

- 0of 0 votes
* Royal titles consist of name followed by space and a Roman numeral. Example: Richard IV. The Roman numeral in the title

* can go to L (50). You are given the roman numerals from 1 to 10:

* I II III IV V VI VII VIII IX X. And you are given the 10 multiples up to 50: XX XXX IL L. Numbers between 10 and 50 that

* are not given can be formed from 10 multiples and a numeral b/w 1 and 9. Example: 48 is XLVIII wichi is XL (40) plus

* VIII (8).

* <p>

* You are given an array of Roman titles sort it as follows: sort it on the name unless the names are equal, in which

* case you have to sort it on the ordinal of the numerals.

* Examples:

* Henry II, Edward VIII => Eward VII, Henry II

* Richard V, Richard II, Richard X => Richard II, Richard V, Richard X

- 0of 0 votes
Design a system for searching strings in files present on a fileserver under a directory. there won't be any sub-directories. There could be more than thousand/lakhs files. And the file size could be in GBs. The matching line should be written to a single file. user will execute grep "string"

The sub-questions are

1) Design where the application executes on single machine.

2) Design where the application can execute on multiple machine.

3) Where could be the potential bottleneck.

4) What component would be bottleneck if 50 cores and slow disk.

5) What component would be the bottleneck if we 4 cores and fast disks.

- 0of 0 votes
Consider an array A of N integers, only permitted operation in this array to reverse the subarray of any length, where the middle index of sub array and middle index of array a are equal. you need to find whether the given array can be sorted using multiple such reverse operations. if sorting is possiable print "Possible". "Not Possible" otherwise.

For example, if the given array is [1,6,3,4,5,2,7] then 2 reverse operations are needed to make this array sorted. first [3,4,5] is reversed to make [1,6,5,4,3,2,7], then [6,5,4,3,2] is reversed to make [1,2,3,4,5,6,7]. so "Possible" should be printed.

Input: first line contains a number N denotes the length of array, Next line contains N numbers separted by spaces.

output : "Possible" if sorting is possible, " Not Possible otherwise.

- 0of 0 votes
a positive non reduceable fractions can be written has x/y where x,y are positive integers, find the count of non

reduceable fractions which is less than 1 for the given N where x,y <=N.

For example , if N=>4 then your output should be 5.

explanation : for N=4 the fractions can be formeted as fallows.

1/1,1/2,2/2,1/3,2/3,3/3,1/4,2/4,3/4,4/4

but 2/4 can be reduce to 1/2, also 1/1,2/2,3/3 and 4/4 is equal to 1, so we can elimi nate those fractions the list and we

have 5 non reduceable fractions whic is less than 1.

input : single number

out put : single number displayed the count of non reduceable fraction less than 1.

- 3of 3 votes
You are given a graph with no cycles, each node representing different cities and there are stadiums for baseball games in all cities.

Each node contains a value representing the population of the city, and a list of neighbors. (feel free to extend data structure)

Every time there is a baseball game at a city, everyone from all the different cities will go to the city with the baseball game.

Return the maximum traffic between a city and its neighbours when there is a game at that city, for all cities. (Does not have to be sorted)

The total run-time after returning everything should be O(n).

Examples:`Input: 1 2 \ / 5 / \ 4 3 Output: 1 14 2 13 3 12 4 11 5 4 Input: 38 / 8 / 7 / 1 2 \ / \ 5 15 / \ 4 3 Output: 1 82 2 53 3 80 4 79 5 70 7 46 15 68 8 38 38 45`

- 0of 0 votes
Given a length n, return the number of strings of length n that can be made up of the letters 'a', 'b', and 'c', where there can only be a maximum of 1 'b's and can only have up to two consecutive 'c's

Example:

findStrings(3) returns 19

since the possible combinations are: aaa,aab,aac,aba,abc,aca,acb,baa,bac,bca,caa,cab,cac,cba,cbc,acc,bcc,cca,ccb

and the invalid combinations are:

abb,bab,bba,bbb,bbc,bcb,cbb,ccc

- 0of 0 votes
Convert a number to English representation.

Ex: Input : 100

Output : One Hundred.

- 0of 0 votes
Given a linked list a random ptr also exists. Clone the original linked list.I was asked to write test cases for it.

- -1of 1 vote
You have a bunch of light bulbs. Store them as you wish. Implement a function that tells you if the light is on or off given its index and another one that toggles the state of the light bulbs given a start and end index.

- 0of 0 votes
You have two very large numbers that cannot be stored in any available datatypes. How would you multiply them?

How would you multiply more than two numbers?