## LAP

BAN USER- -4of 4 votes

AnswersWhat suggestions you can provide for improving the Page Rank algorithm.

- LAP in United States| Report Duplicate | Flag | PURGE

Google Senior Software Development Engineer Algorithm - 0of 4 votes

AnswersGiven - a number (n) and a sorted array

- LAP in United States

Find a number in the array having least difference with the given number (n).| Report Duplicate | Flag | PURGE

Facebook Intern Algorithm - 1of 1 vote

Answers"Write test cases for reversing words of string ". For eg. "This is nice" is input string and output is "nice is This".

- LAP in India

I gave him -

" "

"Hello"

"bye! Mr. X Y. Kumar"

But he didn't seem satisfied.

Can u plz tell what general guidelines should I follow for writing efficient test cases.

What more test cases should I have written for this question ?| Report Duplicate | Flag | PURGE

Microsoft Intern - 33of 39 votes

AnswersGiven an array of integers. Find two disjoint contiguous sub-arrays such that the absolute difference between the sum of two sub-array is maximum.

- LAP in United States

* The sub-arrays should not overlap.

eg- [2 -1 -2 1 -4 2 8] ans - (-1 -2 1 -4) (2 8), diff = 16

I gave him o(n^2) algorithm but he was not satisfied.| Report Duplicate | Flag | PURGE

Google Algorithm - 1of 1 vote

AnswersA pxq size matrix is given, and a matrix of size axb is removed from top right corner. Find the total no. of paths from top left to bottom right, with only right and down movements allowed. No path should go into the removed matrix.

- LAP in India

eg-

_

|_|_

|_|_|

this is (2x2) matrix after removing (1x1) matrix from top right corner. no. of ways - 5.

The algorithm should be fast enough.| Report Duplicate | Flag | PURGE

Microsoft Algorithm

Plz correct me if i am wrong.

in array, it is done by Increamenting the pointer by a fixed known amount.

whereas in case of ll first it will have to access the amount to be increased by accessing the

->next value.

so, in case of array accessing time is saved. So it would be faster.

Greedy approach won't work. I was asked the same question by Amazon and I gave him a greedy approach and the interviewer proved me wrong with a simple example.

Say,

coins = { 1, 10, 25 }

amount = 30

Greedy approach will choose 25 first and then five coins of value 1.

Dynamic will choose 3 10's.

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

I have used the following algorithm described by - IntwPrep.MS

Way to test a point (p,q) is within a triangle is by checking if the area of the triangle is equal to the sum of the three triangles formed with (p,q).

Now to return points within a triangle

- Get a point (p,q) which is within the triangle

- Use flood-fill to generate next points by using the above mentioned condition

- LAP December 29, 2013