Skip to main content

Posts

Showing posts with the label hackerrank challenges

java map hackerrank solution - Java 15

   java map hackerrank solution - Java 15 for explanation watch video : Code: import  java.io.*; import  java.util.*; public   class  Solution {      public   static   void  main(String[] args) {         Scanner scn =  new  Scanner(System.in);          int  n = scn.nextInt();         scn.nextLine();         HashMap<String,Integer> hm =  new  HashMap<>();          for ( int  i= 0 ;i<n;i++){             String name = scn.nextLine();              int  mobile = scn.nextInt();             scn.nextLine();             hm.put(name,mobile);         }          while (scn.hasNext()){             String name = scn.nextLine();              if (hm.containsKey(name)){                 System.out.println(name+ "=" +hm.get(name));             } else {                 System.out.println( "Not found" );             }         }        } }