Panda Guru LogoPanda
Guru

NAB Codility Interview | Checkers board

Round 1

Questions: What is the maximum number of pawns owned by Aladdin that Jafar can beat in his turn?

Write a function:

int solution(char *B[], int N);

which, given a square board of N x N size describing Aladdin's and Jafar's pawns, returns the maximum number of pawns Jafar can beat in one turn. If none of Aladdin's pawns can be beaten, the function should return 0.

Jafar's pawn is described by the 'O' character, Aladdin's pawns by 'X' characters and empty fields by '.' (dots). The board is described from top to bottom and from left to right.

For example, given:

B[0] = "..X..." B[1] = "......" B[2] = "....X." B[3] = ".X...." B[4] = "..X.X." B[5] = "...O.."

the function should return 2 (Jafar can beat Aladdin's pawn in the up-right direction and then another one in the up-left direction).

Given:

B[0] = "X...." B[1] = ".X..." B[2] = "..O.." B[3] = "...X." B[4] = "....."

the function should return 0.

Assume that:

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.