/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{

        Map < String, Set < String > > map =
                Map.of(
                        "laptops" , Set.of( "macbook" , "thinkpad" , "yoga" ) ,
                        "desktops" , Set.of( "macmini" , "imac" , "otherDesktop" ) ,
                        "smartphones" , Set.of( "iphone" , "galaxy5" , "oneplus" )
                );

        // You said: dictionary.get("macbook") would return "laptops"
        Optional < Map.Entry < String, Set < String > > > entry =
                map
                        .entrySet()
                        .stream()
                        .filter( ( Map.Entry < String, Set < String > > stringSetEntry ) -> stringSetEntry.getValue().contains( "macbook" ) )
                        .findAny();
        String result = entry.get().getKey();
        System.out.println( "result = " + result );
        
        
	}
}