Advertisement
cgorrillaha

Untitled

Feb 1st, 2022
1,253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.43 KB | None | 0 0
  1. public static int[] frequency(int[][] arr){
  2.         int[] freq=new int[10];
  3.        
  4. //        for(int[] nums: arr){
  5. //            for(int n: nums){
  6. //                freq[n]++;
  7. //            }
  8. //        }
  9.         for(int i=0; i<arr.length; i++){//row loop
  10.            for(int j=0; j<arr[i].length; j++){
  11.                int num=arr[i][j];
  12.                freq[num]++;
  13.            }
  14.        }
  15.        
  16.        return freq;
  17.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement