Advertisement
ogv

Untitled

ogv
Nov 13th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. class Solution {
  2. public int matrixScore(int[][] A) {
  3. int rows = A.length;
  4. int cols = A[0].length;
  5.  
  6. int sum = 0;
  7. for (int r = 0; r < rows; r++) {
  8. int num = 0;
  9. int p = 1;
  10. for (int c = cols-1; c >= 0; c--) {
  11. if (A[r][c] ==1 ) num += p;
  12. p <<= 1;
  13. }
  14.  
  15. sum += num;
  16. }
  17. return sum;
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement