fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. }
  14. }
  15.  
  16. class Solution {
  17. int findFrequency(int arr[], int x) {
  18. HashMap<Integer,Integer> map=new HashMap<>();
  19. for(int i:arr)
  20. if(map.containsKey(i))
  21. map.put(i,map.get(i)+1);
  22. else map.put(i,1);
  23. if(map.containsKey(x))
  24. return map.get(x);
  25. else return 0;
  26. }
  27. }
Success #stdin #stdout 0.09s 54632KB
stdin
Standard input is empty
stdout
Standard output is empty