• + 1 comment
    int highlightedRect(String string, int[] heights){
            char[] chars = string.toCharArray();
            int maxH = -1;
            for(char a: chars){
                maxH = Math.max(heights[a - 'a'], maxH);
            }
    
            return maxH * string.length();
    
        }
    

    A really small code for this problem. A hashmap would only increase the space complexity