## Recent Interview Questions

- 0of 0 votes
Remove 3 consecutive duplicates from string.

INPUT:aabbbaccddddc

OUTPUT:cdc

- 0of 0 votes
Print first pair of mis-matching leaves (first pair as in in-order) given two pre-order traversal arrays of BSTs.

e.g.`For 5 4 8 2 4 6 9 Pre-order Sequence as [5,4,2,4,8,6,9] & 5 3 8 2 4 7 9 Pre-order Sequence2 as [5,3,2,4,8,7,9] Print “4, 3”.`

- 0of 0 votes
Randomly select one of the weighted items from a linked list. (you may only go through the list once)

e.g.

weight 1.6 -> weight 0.2-> ... -> weight 3.4

randomly select one item based on the weight. The higher the weight is, the more likely to be selected

- 0of 0 votes
Given a list L of numbers from 0 to n, and another number k = [0-9], find how many times k appears in L. If the target number in L is more than one digit, treat each digit separately. For example, k=0 appears twice in L = [0,10].

- 0of 0 votes
Given a list of system packages, some packages cannot be installed until the other packages are installed. Provide a valid sequence to install all of the packages.

e.g.

a relies on b

b relies on c

then a valid sequence is [c, b, a]

- 0of 0 votes
Phone screen Q: String encoding and decoding: Design a method that converts a list of strings into a single string which can be later converted back to the list.

- 0of 0 votes
Q: Find the absolute paths to all directories with image files, given a file system that looks like this. The subdirectory is one indent over.

`/usr /local profile.jpg /bin config.txt dest.png /rbin image.gif /sys /re /tmp pic.jpg ..... ……`

- 0of 0 votes
Q: List all comments in the given segment of codes. It's pretty tricky since there is a lot of things to be considered, especially the escape characters.

- 0of 0 votes
Print elements of a matrix in spiral form.

- 0of 0 votes
Situation - You have millions of records(Strings) and user is typing "abc" in search box . Your task is to display strings from records in the sequence.

e.g String in the record contain "abc" starting should appear first, then string which has "abc" in the second, should apprear later as below.

String - fabcsdf,asdfabc,dfadsfsdfabc,abckdf,ddfabc...

Displays suggestion like....

abckdf

fabcsdf

ddfabc

asdfabc

dfadsfsdfabc

Question - Which data structure you would use to stor this ?

And how will you implement to get this(shorted) result

- 0of 0 votes
Given two strings needle and haywards that contains ASCII characters,write an algorithm to output a list of 0-based indices of the occurances of all anagrams of needle in haystacks

- 0of 0 votes
It was an over email interview:

Write a program that takes as input a sufficiently large text document (several are available online for testing; e.g. via Project Gutenberg), and produces as output (via stdout) an alphabetical listing of each unique word in the document (case insensitive and space separated, though be careful to consider hyphenated words), along with the lines from the input document that the word appears on. Each unique word (and the list of lines that it appears on) should be on a separate line in the output.

For example, taking the following text as input:

This is

some kind OF text it

Is an example of text

The following would be the output:

an 3

example 3

is 1 3

it 2

kind 2

of 2 3

some 2

text 2 3

this 1

- -3of 3 votes
na

- -2of 2 votes
na

- -2of 2 votes
na

- 0of 0 votes
Given a list of list of positive integers, find all pairs of list which are having more than 3 elements overlapping.

What is the complexity.

- 0of 0 votes
You are given an array of integers(with all valid input) You have to write a function which will produce another array, where the value in each index of the array will be the product of all values in the given array accept that index.

Example

Array 1: 1 2 3 4 5

Array 2: 120 60 40 30 24.

Come up with a solution of O(n^2) can you improve it?

- 0of 0 votes
Given 2 sorted linked lists, return a linked list that has all the elements and is sorted.

- 0of 0 votes
Given 3 strings "s" ssearch" and "sreplace", search string s for the substring ssearch and for every instance of ssearch you find, replace that part of the string with sreplace

- 0of 0 votes
Given an NxN Boolean matrix, find how many true regions there are in the matrixj

- 0of 0 votes
Create a basic minesweeper game that allows for board creation with custom height, width and number of mines. Create a <click> function that will take in a board location and return whether the user has won, lost, or the number of surrounding mines.

- 0of 0 votes
Given a string, print out all of the unique characters and the number of times it appeared in the string

- 1of 1 vote
Print the longest path from root to leaf in a Binary tree (Basically the nodes that lie on the height path).

- 1of 1 vote
down vote

favorite

Consider the following series:

A := 1

B := A*2 + 2

C := B*2 + 3 and so on...

Write a program that:

-outputs the number corresponding to a given letter;

-given a string of letters like 'GREP', computes the sum of the numbers corresponding to all the letters in the string (i.e., G + R + E + P), as given by the above series; and

-given a large number (that would fit into a standard 32-bit integer), finds the shortest string of letters corresponding to it. You may use a greedy approach for the last part. Compute the values of the numbers corresponding to letters as and when required and DO NOT pre-compute beforehand and store them in a data structure.

- 0of 0 votes
What is the smallest number *n* by which the given number *x* must be divided to make it into a perfect square?

`n = find_number( x )`

- 0of 0 votes
2.{{ Query the sum of all the data values in a given rectangle (x1,y1) ~(x2, y2).

int querySum(int x1, int y1, int x2, y2) {}}}

- 0of 0 votes
{{Given a two dimensional grid that stores data as integers with the size of N*M, implement write and query functions which supports:

1. Write the given value to designated coordination (x, y).

void write(int value, int x, int y) {}

}}

- 0of 0 votes
Print an NxM matrix with nw-se diagonals starting at bottom left corner. Ex:

`1 2 3 4 5 6 7 8 9 10 11 12`

The output should be:

`9 5 10 1 6 11 2 7 12 3 8 4`

- -2of 2 votes
Write code to traverse a NxM matrix in a zig-zag fashion

- -1of 1 vote
Given a random string (reasonable length L), knowing all possible font sizes (e.g. font Fn has min_width, max_width, min_height, max_height), knowing fixed screen size, find the max font size that can display said string