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 Solution {
  9. int findFrequency(int arr[], int x) {
  10. HashMap<Integer,Integer> map=new HashMap<>();
  11. for(int i:arr)
  12. if(map.containsKey(i))
  13. map.put(i,map.get(i)+1);
  14. else map.put(i,1);
  15. if(map.containsKey(x))
  16. return map.get(x);
  17. else return 0;
  18. }
  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. }
  28. }
Success #stdin #stdout 0.08s 54640KB
stdin
Standard input is empty
stdout
Standard output is empty