Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Frequecy count hashmap
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { Integer ar[] = {1,2,3,1,6,6,1}; int bucket[] = new int[ar.length]; int k=2; Integer count; HashMap<Integer,Integer> hash = new HashMap<Integer,Integer>(); for(int i=0;i<ar.length;i++){ if(!(hash.containsKey(ar[i]))){ hash.put(ar[i],1); } else{ count = hash.get(ar[i]); count++; hash.put(ar[i],count); } } hash.forEach((key,value) ->{ bucket[key] = value; }); for(int i=0;i<ar.length;i++){ if(bucket[i]>=k){ System.out.print(i + " "); } } } }
run
|
edit
|
history
|
help
0
Jh
쓰레드 critical section
Sourab Ghosh @ IP Address
mango
2A
jb6.13 varargs
JAVA İLE CELCIUS HESAPLAMA - Fahrenheit to Celsius with Java
Shortest distance between words
fst
vampires number Eckel B. Thinking in Java