## amnesiac

BAN USER- 2of 2 votes

AnswersYou are given a board with N rows and M columns. In this board you have to place exactly 1 bishop in each row. There are also some obstacles in some of the cells where you can't place a bishop. Bishops can only move diagonally but they can't go to a cell where there is any obstacle. Two bishops can attack each other if one of them can move to the cell of the other bishop. Now you have to count the number of ways that you can place bishops in the board.

- amnesiac in United States

Note: Two bishops can attack each other if one of them can move to the cell of the other bishop in a single move without passing any obstacles.

Input Format

The first line of the input contains two integers N and M. The following N lines contain M characters each, the description of the board. Each cell of the board is either '.' which means that this cell is free or '*' which means that this cell contains an obstacle.

Constraints

1<=N,M<=10

Output Format

Print only one integer representing the number of ways to put exactly one bishop in each row such that no two bishops attack each other.

Sample Input

3 3

..*

.**

.*.

Sample Output

2| Report Duplicate | Flag | PURGE

- 1of 3 votes

AnswersN*N matrix is given with input red or black. You can move horizontally, vertically or diagonally. If 3 consecutive same color found, that color will get 1 point. So if 4 red are vertically then point is 2. Find the winner.

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

Epic Systems Algorithm - 3of 5 votes

AnswersPrint all palindromes of size greater than equal to 3 of a given string. (DP)

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

Epic Systems Software Engineer / Developer Algorithm - 25of 25 votes

AnswersThere is an island which is represented by square matrix NxN.

- amnesiac in India

A person on the island is standing at any given co-ordinates (x,y). He can move in any direction one step right, left, up, down on the island. If he steps outside the island, he dies.

Let island is represented as (0,0) to (N-1,N-1) (i.e NxN matrix) & person is standing at given co-ordinates (x,y). He is allowed to move n steps on the island (along the matrix). What is the probability that he is alive after he walks n steps on the island?

Write a psuedocode & then full code for function

" float probabilityofalive(int x,int y, int n) ".| Report Duplicate | Flag | PURGE

Google Software Engineer / Developer Algorithm - 0of 0 votes

AnswersSort the input character array based on the dictionary given.

- amnesiac in United States

For eg:, If input word is “SHEEP“, sorting will make it as “EEHPS“.

But in the dictionary, E may not be at first. As per the dictionary, if P is first, S followed and E later and finally H.

Then sorted array is “PSEEH“.| Report Duplicate | Flag | PURGE

Google Algorithm - 0of 0 votes

AnswersYou have 8 coins. 3 of them weigh x units, 3 y units, 1 a units and 1 b units. They are all mixed and look identical. You have to find the lightest coin in minimum number of weighing .

- amnesiac in India| Report Duplicate | Flag | PURGE

Oracle Software Engineer / Developer Brain Teasers - 0of 0 votes

AnswersThe two nodes in BST are swapped.Correct the BST.

- amnesiac in India| Report Duplicate | Flag | PURGE

Microsoft Software Engineer / Developer Coding

This is maximum sub-array problem...use the divide & conquer method.

recursively divide the array into two sub-parts left & right.

find max left sum.max right sum & max cross sum whichever is greater return that.

Algorithm:

function(A,low,high)

{

mid=(low+high)/2

(left-low,left-high,left-sum)=function(A,low,mid);

(right-low,right-high,right-sum)=function(A,mid+1,high);

cross-low,cross-high,cross-sum=find max-crossing subarray(A,low,mid,high)

if(leftsum>=rightsum && leftsum>=cross-sum)

return (left-low,left-high,left-sum);

else if (leftsum<=rightsum && rightsum>=cross-sum)

return (right-low,right-high,right-sum);

else

return (cross-low,cross-high,cross-sum);

}

find-cross-subarray(A,low,mid,high)

{

find left max sum from i=mid to low & store that cross-low=i

find right max-sum from i=mid+1 to high & store that cross-high=i ;

return (cross-low,cross-high,left-sum+right-sum)

}

Time complexiety: O( n logn )

When making a move, the computer first checks to see if it can win by putting an X/O into one of these three squares.

If it cannot win, it checks to see if it has to block X from winning on the next move by putting an X/O into one of these three squares.

If neither of these two conditions holds, the computer checks to see if it has to move into one of these squares to block X from winning in two moves. If it can't win and doesn't need to block X on the next one or two moves, the computer chooses an arbitrary location for its move.

is there any better way?

Rep**hollymclark8**, Apple Phone Number available 24/7 for our Customers at AccentureI am clinical laboratory technologist in Stratapro company. I have Excellent clinical laboratory skills, with commended performance conducting/analyzing laboratory ...

Rep**karinkwalton**, Backend Developer at BroadsoftI am working as a Support clerk in an MVP Sports company. I love traveling and exploring facts about technology ...

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

everyone... please explain your logic ..ther is no use of code..no one is gonna sit & read the big code...

- amnesiac June 20, 2012so try to mention the logic /important aspects of program.. so that everyone understands.