• + 0 comments

    Simple Java Code to Understand

     public static int designerPdfViewer(List<Integer> h, String word) {
        
            Map<Character,Integer> map = new HashMap<>();
            Character ch = 'a';
            for(int i=0;i<h.size();i++){
                map.put(ch, h.get(i));
                
                if(ch == 'z'){
                 break;   
                }
                ch++;
            }
            
            char[] chArray = word.toCharArray();
            List<Integer> itr = new ArrayList<>();
            for(Character chr : chArray){    
                itr.add(map.get(chr));
            }
            
            int highestValue = Collections.max(itr);
            int n = itr.size();
            
            int areaOfRech = highestValue * n;
            
            return areaOfRech;
    
        }