## Twitter Interview Questions

- 0of 0 votes
Solve the 24 Game

- 0of 0 votes
There is a DNA Strand having values as A , T , C , G.

All combinations are present in the the file.

Write a method which takes starting mutation string , ending mutation string and string bank and calculates the minimum mutation distance required. But the condition is that either of the start or end must be present in the bank.

Input:

AATTGGCC is starting and TTTTGGCA is ending then mutation distance will be 3.

AATTGGCC - TATTGGCC - TTTTGGCC - TTTTGGCA as it takes three mustaion for start to reach the end string and for this , all intermediate string and final string must be present in the bank.

static int findMutationDistance(String start, String end, String[] bank) {

}

- 0of 0 votes
You have a string of phrases present. For your simplicity consider them to be integer length.

String s= " I am Tom"

will be stored in an interger array as [1,2,3] where each represents length of each word in the string.

Write a method to compute the longest subsequence such that it is less than given k value.

Input:

3 //length of array

1 //a[0]

2 //a[1]

3 //a[2]

4 // value of k

Output:

2

Input:

4 //length of array

3

1

2

1

4 //value of k

Output:

3

static int maximumLength(int[] a, int k) {

}

- 1of 1 vote
Find the anagrams from a list of strings

Input : {"tea", "ate", "eat", "apple", "java", "vaja", "cut", "utc"}

Output : {"tea", "ate", "eat","java", "vaja", "cut", "utc"}

- 0of 0 votes
Stanford has to select a team of dodgeball players from its class of 2013. There are n students in the class and each student is identified by his/her student ID, which is between 1 and n. The coach has to select K players out of these n students for his team. But there is a twist, if among the K dodgeball players, a player's ID number evenly divides another player's ID number, then there is a high chance of them getting into a fight. The coach will do his best to select the K players so that no pair of players among them will want to fight one another. But if the game turns out to be very popular, this becomes impossible. Complete the function dodgeBall to return the minimum size of K at which it becomes impossible to choose a dodgeball team that has no fighting?

Input Format:

One line of text, containing the size of the class of 2013, n

Constraints:

1 <= n <= 5,000,000,000

n is guaranteed to be an even number

Output Format:

The minimum size of K that guarantees the existence of 2 players who fight with each other in any K-sized subset of the class.

Sample Input:

4

Sample Output:

3

Explanation:

If the team = {1,2,3}: 1&2 or 1&3 can fight with each other

If the team = {1,3,4}: 1&3 or 1&4 can fight with each other

If the team = {2,3,4}: 2&4 can fight with each other

If K=2, then the teams {3,4} or {2,3} will have no fights. So 3 is the smallest value of K for which any K-sized team, must include a fighting pair.

Sample Input:

2

Sample Output:

2

Explanation:

The team = {1,2}: 1&2 can fight with each other

- 0of 0 votes
Design a unique hash function for every tweet in Twitter which will be used as part of a service.

- 1of 1 vote
Given an array of task and k wait time for which a repeated task needs to wait k time to execute again. return overall unit time it will take to complete all the task.

Example:

1. A B C D and k = 3

ans: 4 (execute order A B C D)

2. A B A D and k = 3

ans: 6 (execute order A B . . A D)

3. A A A A and k =3

ans: 13 (A . . . A . . . A . . . A)

4. A B C A C B D A and k = 4

ans: 11 (A B C . . A .C B D A )

- 0of 0 votes
Design Twitter.

- 1of 1 vote
1) You have a folder full of .bin files that are proprietary.

2) You have a class called converter with a "binToTSV" method which you can pass the name of a .bin file and will generate a .tsv file.

3) The TSV file is a tab separated value file with a key on each line, and a value next to it spaced with a tab as such.

-------

num_connections 65

latency_ms 70

bandwidth 20

.... //etc.

-------

Q: Write a method to calculate the average latency and total bandwidth.

- 0of 2 votes
Objective: Write a function to find all the combinations of three numbers that sum to zero

Sample input:

[2, 3, 1, -2, -1, 0, 2, -3, 0]

Sample output:

2, -2, 0

1, -1, 0

3, -2, -1

3, 0, -3

3, 0, -3

- 1of 1 vote
write a function that has an int as input and return the equivalent String as an output

12 -> 'twelve'

4345 -> 'four thousand three hundred and forty-five'

7654567643 -> 'seven billion six hundred and fifty-four million five hundred and sixty-seven thousand six hundred and forty-three'

- 0of 2 votes
You have n - 1 numbers from 1 to n. Your task is to find the missing number.

I.e.

n = 5

v = [4, 2, 5, 1]

The result is 3.

- -2of 2 votes
Given an array with numbers, your task is to find 4 numbers that will satisfy this equation:

A + B + C = D

- 1of 1 vote
given two nodes of a binary tree, find number of nodes on the path between the two nodes.

`1 2 3 4 5 4, 3 -> (4-2-1-3): 4`

- -4of 4 votes
Two sorted 2D arrrays, get the third one sorted

A = [["a", 1], ["b", 2]] sorted all elements have different names

B = [["a", 2], ["c", 3]] sorted

C = [["a", 3], ["b", 2], ["c", 3]] sorted

- 1of 3 votes
Implement LRU cache.

- 0of 0 votes
Given a list of names. Find whether a particular name occurs inside a given tweet or not. If found return true otherwise false Time complexity should be less than O(n).

Ex: "Katy Perry","Ronan Keating" given as a list of string.

List<String> names;

bool findName(String tweet)

{

}

- 0of 0 votes
Given a preorder sequence from a Binary Tree, how many unique trees can be created from this? (They want a recurrence relation and start with the easy cases):

T(0) = 1

T(1) = 1

T(2) = 2

What is T(N) ?

- -2of 4 votes
For a technical phone screen:

Given a string "aaabbcccc", write a program to find the character with the second highest frequency.

- 0of 0 votes
given 4 points, whose x and y coordinates are both integers. they are all different. write a function to check if they form a square.

i forgot to point out that the points can be given in any order

- 0of 0 votes
Write a method to validate that given Binary tree is a BST.

- 0of 0 votes
Given a Tuple for eg. (a, b, c)..

Output : (*, *, *), (*, *, c), (*, b, *), (*, b, c), (a, *, *), (a, *, c), (a, b, *), (a, b, c)

- 1of 1 vote
String getSentence(String text, Set<String> dictionary);

// text is a string without spaces, you need to insert spaces into text, so each word seperated by the space in the resulting string exists in the dictionary, return the resulting string

// running time has to be at least as good as O(n)

// getSentence("iamastudentfromwaterloo", {"from, "waterloo", "hi", "am", "yes", "i", "a", "student"}) -> "i am a student from waterloo"

- 0of 0 votes
Build an HTTP Library that is common and can be used by various clients like Twitter, Gmail, facebook etc. What features would you add into this library

- 0of 0 votes
Write a class hashmap and implement: insert, get and delete (Open addressing/chaining). What points to be considered before going to production (focus on concurrency)

- 0of 0 votes
Design a modified stack that in addition to Push and Pop can also provide minimum element present in the stack via Min function.

- 0of 0 votes
Design a hash table that is thread safe. That is it can support concurrent reads but protects on write.

- 1of 1 vote
Design a collaborative text editor where each participant has infinite undo/redo. Consider the scenario where a user goes offline and then comes online and tries to undo/redo.

- 0of 0 votes
Given a sorted array that is sorted by rotated, find a given number. For example take an array: 1 3 8 10 12 56 and rotate it so you have 10 12 56 1 3 8 and then find a candidate e.g. 3 in it.

- 0of 0 votes
Given a string representing sorted numbers with spaces print the count of each number. For example if the input string is: "1 1 2 3 4 4" then you should print 1:2, 2:1, 3:1, 4:2

Then the question was modified so there could be invalid number in the string which must be skipped.

Then an added requirement to handle hex numbers in the string.