Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Ex4 {
- public static void main(String[] args) {
- int[] arr = {1, 2, 3, 4, 1, 2, 3, 4, 5, 8, 9, 6};
- int max = Integer.MIN_VALUE;
- for (int i = 0; i < arr.length; i++) {
- if (arr[i] > max) {
- max = arr[i];
- }
- }
- int[] arr1 = new int[max + 1];
- for (int i = 0; i < arr.length; i++) {
- arr1[arr[i]]++;
- }
- for (int i = 0; i <= max; i++) {
- if(arr1[i] != 0){
- System.out.println(i + " " + "->" + " " + arr1[i]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement