package leetcode;

/**
 * https://leetcode.com/problems/available-captures-for-rook/
 */
public class Problem999 {
    public int numRookCaptures(char[][] board) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem999 prob = new Problem999();
    }
}

@@ -169,128 +169,1820 @@
     
-// TODO%0A        return 0;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem999 prob = new Problem999()
+int answer = 0;%0A        int maxRow = board.length;%0A        int maxCol = maxRow %3E 0 ? board%5B0%5D.length : 0;%0A        outer:%0A        for (int i = 0; i %3C maxRow; i++) %7B%0A            for (int j = 0; j %3C maxCol; j++) %7B%0A                if (board%5Bi%5D%5Bj%5D == 'R') %7B%0A                    // up%0A                    for (int k = i - 1; k %3E= 0; k--) %7B%0A                        if (board%5Bk%5D%5Bj%5D == '.') %7B%0A                            continue;%0A                        %7D%0A                        if (board%5Bk%5D%5Bj%5D == 'p') %7B%0A                            answer++;%0A                        %7D%0A                        break;%0A                    %7D%0A                    // right%0A                    for (int k = j + 1; k %3C maxCol; k++) %7B%0A                        if (board%5Bi%5D%5Bk%5D == '.') %7B%0A                            continue;%0A                        %7D%0A                        if (board%5Bi%5D%5Bk%5D == 'p') %7B%0A                            answer++;%0A                        %7D%0A                        break;%0A                    %7D%0A                    // down%0A                    for (int k = i + 1; k %3C maxRow; k++) %7B%0A                        if (board%5Bk%5D%5Bj%5D == '.') %7B%0A                            continue;%0A                        %7D%0A                        if (board%5Bk%5D%5Bj%5D == 'p') %7B%0A                            answer++;%0A                        %7D%0A                        break;%0A                    %7D%0A                    // left%0A                    for (int k = j - 1; k %3E= 0; k--) %7B%0A                        if (board%5Bi%5D%5Bk%5D == '.') %7B%0A                            continue;%0A                        %7D%0A                        if (board%5Bi%5D%5Bk%5D == 'p') %7B%0A                            answer++;%0A                        %7D%0A                        break;%0A                    %7D%0A                    break outer;%0A                %7D%0A            %7D%0A        %7D%0A        return answer
 ;%0A  

Solve problem 999