title: Java: How to get set of keys having same value in hashmap
body: <p>I have a hashmap as below:</p>
  
  <p>1->x</p>
  
  <p>2->y</p>
  
  <p>3->x</p>
  
  <p>4->z</p>
  
  <p>Now i want to know all keys whose value is x (ans: [1,3] ). what is best way to do?</p>
  
  <p>Brute force way is to just iterate over map and store all keys in array whose value is x. </p>
  
  <p>Is there any efficient way for this.</p>
  
  <p>Thanks</p>