## A9 Interview Questions

- 0of 0 votes
Testing Strings

Mr X and Mr Y, his friend are programmers and testers respectively working in the same company. So, once they faced the following scenario :

Mr X wrote an application that took as input some user data. The data the application took as input was a string in some strange language. That language consisted of

K

K distinct letters. However, due to some issues, the application got corrupted and one particular String among many was lost.

However, Mr X had seen that String once before it got lost. He remembers some info about it. Particu-larly, he remembers the lost String had length equal to

M

M.

Mr Y, being the chief QA person in his company needs to try and figure out the number of possible different possible candidate Strings for the lost String.

Mr X remembers N pieces of info. For each one, he gives you 2 numbers

L

L and

R

R and a number

Z

Z. He remembers for sure that the

Z

t

h

Zth letter of the language of the string did not occur between positions

L

L and

R

R inclusive of the lost String.

Input Format :

The first line contains

3

3 space separated integers

N

N ,

M

M and

K

K.

Each of the next

N

N contains

3

3 space separated integers, denoting

L

L ,

R

R and

Z

Z respectively.

Output Format :

You need to find and print the number of different possible candidate Strings for the lost String based on the info Mr X remembers. As the number of such Strings can be large, print it Modulo

10

6

+

3

106+3

Constraints:

1

≤

N

,

M

,

K

≤

10

5

1≤N,M,K≤105

1

≤

L

≤

R

≤

M

1≤L≤R≤M

1

≤

Z

≤

K

1≤Z≤K

Sample Input

1 2 26

1 2 1

Sample Output

625

- 0of 0 votes
Today Jin has given a task to Shino, Shino has to travel from cell

(

1

,

1

)

(1,1) to cell

(

N

,

M

)

(N,M) in a grid of size

N

∗

M

N∗M. But in order make this task interesting for Shino, Jin has decided to keep some special candies in some

K

K special cells of the grid, where each candy has an amount of happiness associated with it.

Shino can travel only in right & down direction in the grid, as he is too careful & does not want to fall out of grid. Now, we call the value of a path the happiness of all cells lying on the path. All non-special cells have happiness equal to

0

0.

Now, you need to find and print the sum of the values of all paths from

(

1

,

1

)

(1,1) to

(

N

,

M

)

(N,M), traveling only right and down to an adjacent cell.

As Shino is not good at counting help him find the answer.

Input Format

The first Line contains a single integer

T

T denoting number of test cases

The next line contains

3

3 space separated integers,

N

N,

M

M and

K

K where N * M is the size of grid & K denoting number of special cells

The next

K

K lines contains three integers

X

i

,

Y

i

,

H

i

Xi,Yi,Hi where

(

X

i

,

Y

i

)

(Xi,Yi) is cell coordinate &

H

i

Hi is the amount of happiness Shino will get from a candy at cell

(

X

i

,

Y

i

)

(Xi,Yi)

Constraints

1

≤

T

≤

3

1≤T≤3

1

≤

N

,

M

,

K

≤

10

5

1≤N,M,K≤105

1

≤

X

i

≤

N

,

1

≤

Y

i

≤

M

1≤Xi≤N,1≤Yi≤M

1

≤

H

i

≤

10

5

1≤Hi≤105

Output Format

For each test case you will output a single integer denoting the total amount of happiness Shino will get. As the answer can be quiet large you can output answer modulo

10

9

+

7

109+7

Sample Input

1

2 2 2

1 2 4

2 1 7

Sample Output

11

- 0of 0 votes
You have a long string that contains of 0's and 1's, seprated with some delimiter (like "!"). the number of delimeters after each 0 or 1 is between 1 to 3.

for example a string such as 0! 1!!! 0!! 1!! 0! 1! 0!!! 1!! 0!! (and so on...)

Take this long string and convert it to a 7 digits number by some porgramming algorythem,

(you can use every lanugage you want)

- 0of 0 votes
Given (a,b) can you reach to (c,d) if a and b can move either (a+b,b) or (a,a+b). Example a =1, b=4,c=5,d=9 then (1,4) -> (5,4) -> (5,9)

- 0of 0 votes
A List contains objects (a collection even). On iterator.next(), if a collection is encountered it should traverse it until it finds an object(not collection). Entering list.get(4) should give the object at 4th position

List contains - String, Double, List(Double, Person), List(Employee, Long). list.get(4) should return Employee

write a java function?

- 0of 0 votes
Write a program to detect cycle in loop.

- 0of 0 votes
Write a program to sort an array in nlog(n) complexity

- 0of 0 votes
Write an algorithm to randomize nodes of a Binary Tree without using any data structures

- -5of 5 votes
wkhdqwdhqowdh

- -5of 5 votes
Hello, I am moving to Brazil and I am looking for a property in São Paulo hear about Lopes, someone knows? She is good ?

http://www.lopes.com.br/

- 1of 1 vote
Given an unsorted array, find Kth smallest element in it.

A = 12, 3, 17, 0, 9, 6, 100

K = 3 -> 6

- 0of 0 votes
write a function that takes two integers, k and n, with 0 ≤ k ≤ n, and prints out all subsets of size k of the integers 1, ..., n, one subset per line. The order of the subsets and the order of elements within the line doesn't matter.

example 1: print_subsets(k=1, n=2);

1

2

example: print_subsets(k=2, n=3);

3 1

2 3

1 2

- 1of 3 votes
New CareerCup Android App!!!

Hey Guys,

Lately I was trying to get android app for this website and no single app was good enough for me.

So I thought of developing it myself. After 2 weekends of work I released first version of the app. With lot more new features lined up.

Please download it here

https://play.google.com/store/apps/details?id=com.careercup

and give your reviews and ratings.

Thanks

- 1of 1 vote
You are given a file which contains 3 values - start time, end time, amount of water flowing between the start time and end time for one day

The start time and end time may overlap and are inclusive. The times are not in a sorted order

Example:

0,10,100

10,15,300

16,20,400

5,15,200

Find the max flow of water at any instant of time.

In the above example, the answer is 600 ( at instant 10)

- 0of 2 votes
You are driving a bus along a highway, full of rowdy, hyper, thirsty students and a soda fountain

machine. Each minute that a student is on your bus, that student drinks one ounce of soda. Your

goal is to drop the students off quickly, so that the total amount of soda consumed by all students

is as small as possible.

You know how many students will get off of the bus at each exit. Your bus begins somewhere

along the highway (probably not at either end) and move s at a constant speed of 37.4 miles per

hour. You must drive the bus along the highway; however, you may drive forward to one exit then

backward to an exit in the opposite direction, switching as often as you like. (You can stop the

bus, drop off students, and turn around instantaneously.)

Describe an efficient algorithm to drop the students off so that they drink as little soda as

possible. Your input consists of the bus route (a list of the exits, together with the travel time

between successive exits), the number of students you will drop off at each exit, and the current

location of your bus (which you may assume is an exit).

I gave a recursive solution but he insisted on dynamic programming which i couldn't give

- 0of 0 votes
If we have all the variables and methods are as static. So would that class be thread safe?

- -1of 1 vote
there is PCB robot move from point of beginning go to destination find the shortest distance/shortest path from starting to destination

- 2of 2 votes
Problem Statement

You have two strings A and B. Each one contains some letters and exactly one asterisk.

You have to replace the asterisk in each string with a letter sequence (possibly of zero length) so that the resulting two

strings are equal. This equal string is what you have to return. Attempt to return the shortest possible string.

The letter sequences may be same or different.

If it is not possible to make the given strings equal, return the string "not-possible".

Additional Constraints

- A and B will contain only uppercase letters and asterisks.

- A and B will contain one asterisk each.

Examples

0)

"SOCIA*TWIST"

"SOCIALTWI*T"

Returns: "SOCIALTWIST"

1)

"HELLO*"

"HI*"

Returns: "not-possible"

2)

"PROFESS*"

"*PROFESS"

Returns: "PROFESS"

3)

"*EXAMPLETEST"

"THIRDEXAMPLE*"

Returns: "THIRDEXAMPLETEST"

4)

"*TELL"

"*AFRIEND"

Returns: "not-possible"

5)

"*"

"B*"

Returns: "B"

6)

"*C"

"D*"

Returns: "DC"

program should be written in java

- 0of 0 votes
You type www.yahoo.com on the browser . But it will display

nothing or blank page.what is the problem?How will you resolve/

- 2of 6 votes
COUNT 1s in BINARY FORMAT OF A NUMBER.

- 4of 8 votes
Given a matrix with only 1s and 0s now find and PRINT SUB MATRIX WITH EQUAL NUMBER OF 0s AND 1s.

- 2of 2 votes
Given a list of stock quotes over a month of time,

Return the buy day and sell day which gives the max

profit.

- 0of 0 votes
Given an array of integers and the target as an input E.g.

input = {5,2,1,4,3,6,7,8} .. target : 333 it should true as (5 +214 + 36 + 78) if the target does not match it should return false.... Eg. of false input : {5,5} target:60 ... It should return false as the combinations possible are 5+5 = 10 and 55

- 0of 0 votes
There are total of n boxes kept in a single row next to each other .

Each box has weight W(i) .

How to split the boxes into two groups such that the difference between the total weight of the two groups is minimum and

the boxes in each group maintain the order in which they were initially.Also there is a condition that there if the total number of boxes is even ,

then both the groups should have n/2 boxes and if n is odd , one group should have (n-1)/2 and other (n+1)/2 boxes.

for example....

lets say there are 3 boxes of weight 6,12,5.

then the solution would be that one group has 6,5 and other has 12

- 0of 0 votes
Given a random number generator say r(5) generates number between 1-5 uniformly at random , use it to in r(7) which should generate a random number between 1-7 uniformly at random.

- 0of 0 votes
Given a big list of "n" integers stored in the disk compute the Top "k" , assume k << n and sizeof(n) > sizeof RAM .

- 0of 0 votes
Given an array of n elements, how would you compute product of all (n-1) groups of elements? Take care of any corner cases too.

- 0of 0 votes
What different types of joins are there in SQL?

- 0of 0 votes
How will you do inheritance in C without using any C++ constructs?