Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public int matrixScore(int[][] A) {
- int rows = A.length;
- int cols = A[0].length;
- int sum = 0;
- for (int r = 0; r < rows; r++) {
- int num = 0;
- int p = 1;
- for (int c = cols-1; c >= 0; c--) {
- if (A[r][c] ==1 ) num += p;
- p <<= 1;
- }
- sum += num;
- }
- return sum;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement