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.  
  9. class Solution {
  10. int findFrequency(int arr[], int x) {
  11. HashMap<Integer,Integer> map=new HashMap<>();
  12. for(int i:arr)
  13. if(map.containsKey(i))
  14. map.put(i,map.get(i)+1);
  15. else map.put(i,1);
  16. if(map.containsKey(x))
  17. return map.get(x);
  18. else return 0;
  19. }
  20. }
  21.  
  22. class Ideone
  23. {
  24. public static void main (String[] args) throws java.lang.Exception
  25. {
  26. // your code goes here
  27. Solution s = new Solution();
  28.  
  29. }
  30. }
Success #stdin #stdout 0.07s 54640KB
stdin
Standard input is empty
stdout
Standard output is empty