## Recent Interview Questions

- 0of 0 votes
Given a string S(a data structure) that contains only square brackets, convert it to an array that stores arrays in the following format: [positionOpeningBracket, positionClosingBracket, nestedDataStructure]. Example: https://i.imgur.com/vZhlZdr.png

`def parser(S): #whatever... print(r) parser("[[]][]") #output: [[0,3,[1,2,null]], [4, 5, null]]`

- 0of 0 votes
‘.’Matches any single character,' * 'Matches any sequence of characters (including the empty sequence).

There are two input, one is string pattern, and the other is dictionary like dict = ["cat", "cats", "and", "sand", "dog"].

return a boolean: whether to find a dictionary in the pattern match the word

eg: dict = ["cat", "cats", "and", "sand", "dog"].

pattern = "* t", -> true (can match cat)

pattern = ".a *" -> true (can match cat, cats, can also match sand, because * can also express empty sequence)

- 0of 0 votes
Given a set of strings (denoting URLs), like:

1. abc.pqr.google.com

2. pqr.google.com

3. pqr.google.net

4. yahoo.com

5. abc.yahoo.com

etc...

find an efficient way to find out how many times a particular string appears as a substring. For e.g., given the above set of strings, "google.com" appears twice; ".com" appears four times, "pqr.google.com" appears twice, and so on.

Follow up: How would you do this, if the input was no longer a URL (So, "abc.pqr.google.com" and "pqr.abc.google.com", both are valid)?

- 1of 1 vote
Given a number line from -infinity to +infinity. You start at 0 and can go either to the left or to the right. The condition is that in i’th move, you take i steps.

- 0of 0 votes
AT&T Customer service email. Smart and experienced technicians for AT&T email issue. They can find your email issue and resolved it as you want in your way. Our Cox email technicians are available on Cox email service we have 24*7 technical support is available throughout the day. Customize antivirus setting according to your need. Or you are getting difficulty to send and receive mail to the concerned person. Or File attachment is not possible. We are here to give you all setup in your email account for secure your web email application. AT&T customer service number gives best and cheap service you. Click on our website link for more information.

http://www.email-customer-care.com/att-support

- 0of 0 votes
How would you store and retrieve values in Memcache if the values are larger than the individual value size allowed by Memcache?

- 1of 1 vote
You are a game developer working on a game that randomly generates levels. A level is an undirected graph of rooms, each connected by doors. The player starts in one room, and there is a treasure in another room. Some doors are locked, and each lock is opened by a unique key. A room may contain one of those unique keys, or the treasure, or nothing.

Implement a representation for a level and write code that, given a level and starting room, returns true if the treasure can be reached by the player—likely requiring them to find certain other keys first—or false if there is no solution.

- 3of 3 votes
Question 1.

You are given a string composed of uppercase English letters (‘A’ through ‘Z’).

Set of letters (‘A’, ‘E’, ‘I’, ‘O’, ‘U’) are called vowels. Other letters are called consonants.

We define foo value of a string as number of pairs of exactly same consecutive vowel letters.

For example,

Ex.1: BCDEEIOU - This has a foo value of 1 (because of EE). Note that although I is next to E, and O is next to I, and U is next to O, they aren’t exactly same neighbours, so they don’t contribute to foo value

Ex.2: BCDEEEIOU - This has foo value of 2. Because of first pair of EE and immediately next pair of EE

Ex.3: ABCDEFG - This has foo value of 0. There are no consecutive vowels

Ex.4: ABEUUOUOO - This has foo value of 2, because of UU and OO

You are given 2 inputs, N and K.

How many strings of length N can you form such that they all have foo value of K?

Let’s assume the constraints as:

1<=N<=15

0<=K<N

- 2of 2 votes
node {

node * left, * right;

}

Given a list of node to determine whether the node in the list can form a valid binary tree. several points of judgment

1. need to ensure that all left, right pointer point to the node inside list

2. no cycle

3. All node must be connected

Boolean isValidTree(List<Node> list){}

- 1of 1 vote
Given a matrix of N * M, given the coordinates (x, y) present in a matrix,

Find the number of paths that can reach (0, 0) from the (x, y) points with k steps (requires exactly k, k> = 0)

From each point you can go up, down, left and right in four directions.

For example, the following matrix:

----------

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

(x, y) = (1, 1), k = 2, the output is 2

- 0of 0 votes
Can we solve sudoku without using extra space like mentioned here -

http://letstalkalgorithms.com/check-if-a-sudoku-is-valid

Interview Preparation Resources - http://letstalkalgorithms.com

- 0of 0 votes
Given that :

A -> 1

B -> 2

…

Z -> 26

AA -> 27

AB -> 28

…

BA -> 53

Write a function that returns the value given a string of uppercase letters.

- 0of 0 votes
Find all words [A-Z] in a dictionary (about 1M words) that are made of a subset (in any order) of the chars in the input parameter [A-Z].

ex: input "ACRAT" (10 to 20 chars, up to 30 worst case)

matching words: "A", "CAR", "ACA", "ART", "RAC".

non-matching words: "BAR", "AAA"

follow up : the input is a list of words. Return a list of words that each

list is formed by exactly the characters in the input list.

For example: two lists {“DEBIT”, “CARD”} and{“BAD”, “CREDIT”}

are formed by the same exact group of characters.

- 0of 0 votes
Given a sorted list of integers, square the elements and give the output in sorted order.

- 0of 0 votes
Find the distance between the farthest two elements in a binary tree.

- 0of 0 votes
Given a non-negative integer n, check if it is possible to build a pyramid of '*' and empty spaces where first row has one '*' and second has three '*' and so on.

For example-

Input: n =4 Output: True

Explanation : The pyramid can be build

*

***

Input: n = 9 Output: True

Explanation : The pyramid can be build

*

***

*****

Input: n = 6 Output: False

Explanation : The pyramid cannot be build as last row will be incomplete

*

***

**

- 0of 0 votes
Given a string separated by a space like "123456 abc+efg" determine

the solution by mapping integers to letters like a:1, b:2, c:3, d:4, e:5, f:6.

The only operations allowed were + or -. So the calculated solution

that made the tests pass was 123+456 = 579.

- 0of 0 votes
How many subsets of a given array sum to zero?

- 0of 0 votes
Given numbers 1 through 52, take 5 unique numbers and determine

if the number 42 can be made using any combination of addition (+),

subtraction (-), multiplication (*), and division (/) on those 5 numbers

- 1of 1 vote
Write a Java code that take a string of parenthesis as input and return if the string is valid or not . The input will have '(' and ')' and also '*' and * serves as wild card and can be used in place of both '(' and ')' or it can be null.

For example,the String (*)(*)(** is a valid String.

Follow up: What if '[]' and '{}' are also in the string along with '()' and * can be used in place of any of them or can be considered as null?

- 0of 0 votes
given two array of elements representing the connection Nodes output the topology used?

Topology can be either Bus , circular or Star

input:

Number of nodes 3

Number of Connections : 2

{1,2}

{2,3}

Output Bus

Explanation

the topology formed would be 1->2->3 . hence Bus

input

number of nodes : 3

Number of connections : 3

{1,2,3}

{2,3,1}

Output: Circular

the topology formed is 1->2->3->1

hence circular

input:

number of nodes : 5

Number of connections : 5

2 3 4 5

1 1 1 1

Answer : StarTopology

Explanation : A star can be formed with this input

2 4

1

3 5

StarTopology

- 0of 0 votes
Magical binary strings are non-empty binary strings if the following two conditions are true:

1. The number of 0's is equal to the number of 1's.

2. For every prefix of the binary string, the number of 1's should not be less than the number of 0's.

A magical string can contain multiple magical substrings. If two consecutive substrings are magical, then we can swap the substrings as long as the resulting string is still a magical string. Given a magical binary string, str, perform zero or more swap operations on its consecutive magical substrings such that the resulting string is as lexicographically large as possible. Two substrings are considered to be consecutive if the last character of the first substring occurs exactly one index before the first character of the second substring.

Input Format

a single binary string, str.

Constraints

It is guaranteed that str is a binary string of 1's and 0's only.

1 ≤ length(str) ≤ 50

It is guaranteed that str is a magical string.

Output Format

Find a string denoting the lexicographically largest magical string that can be formed from str.

Sample Input 0

11011000

Sample output

11100100

Explanation of sample

Given the magical string str = 11011000, we can choose two consecutive magical substrings, 1100 and 10, to swap such that the resultant string, str' = 11100100, is the lexicographically largest possible magical string possible. Thus, we return the value of str', which is 11100100, as our answer.

- 0of 0 votes
`A text file contains {candidateID,voterID} details of an ongoing voting. Read this file in real time and report top 5 candidates. Also report a fraud if a Voter tries to vote twice or try to vote more then one candidate. Assume that the database is offline.`

- 0of 0 votes
Given an unsorted array of unique integers, find two numbers in the array whose sum is equal to a given number.

- 0of 0 votes
Given list of line segments({x_start, y_start}, {x_end, y_end}) find out the maximum number of points they intersect. (interviewer said, he can make it simpler by assuming only vertical or horizontal lines with no overlapping lines)

Givenen tree in which each node has (or grows) exactly 4 children with values (2, 2.5, 8, 50) plus the value of its parent node. Find out the least K values.

e,g, k = 5, node with value 2, 2.5, 4, 4.5, 6

- 0of 0 votes
List of processes with start time, end time and bandwidth. Find the maximum bandwidth for the list.

2. Given N teams which need to play each other exactly once but at most once in one day, output the game schedule.

- 0of 0 votes
Snake and ladder game. Given a board state with position information for snakes and ladders, find the minimum number of ways(aka dice throws) one can reach from start to end.

- 0of 0 votes
Longest substring palindrome

(interview looking for n^2 or less solution)

- 0of 0 votes
alphaAndarabic

given a set of character, ex: 'A' 'B' 'C',

each char have its representative number:

A = 1, B = 13, C= 110;

when the char next to current index is smaller than current we add ex: CBA = 110+13+1

when the char next to current index is bigger than current we all the answer in prev will become minus sign(but not the last one) ABC -1 - 13 + 110 = 96;

calculate the number for each string input;

- 1of 1 vote
Airbnb Online Assessment Paginate List

5

13

1,28,310.6,SF

4,5,204.1,SF

20,7,203.2,Oakland

6,8,202.2,SF

6,10,199.1,SF

1,16,190.4,SF

6,29,185.2,SF

7,20,180.1,SF

6,21,162.1,SF

2,18,161.2,SF

2,30,149.1,SF

3,76,146.2,SF

2,14,141.1,San Jose

Here is a sample input. It’s a list generated by user search.

(1,28,100.3,Paris) corresponds to (Host ID, List ID, Points, City).

5 in the first row tells each page at most keeps 5 records.

13 in the second row is the number of records in the list.

Please paginate the list for Airbnb by requirement:

1. When possible, two records with same host ID shouldn’t be in a page.

2. But if no more records with non-repetitive host ID can be found, fill up the page with the given input order (ordered by Points).

Expected output:

1,28,310.6,SF

4,5,204.1,SF

20,7,203.2,Oakland

6,8,202.2,SF

7,20,180.1,SF

6,10,199.1,SF

1,16,190.4,SF

2,18,161.2,SF

3,76,146.2,SF

6,29,185.2,SF -- 6 repeats in page bec no more unique host ID available

6,21,162.1,SF

2,30,149.1,SF

2,14,141.1,San Jose