You are viewing a single comment's thread. Return to all comments →
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
Seems like cookies are disabled on this browser, please enable them to open this website
Designer PDF Viewer
You are viewing a single comment's thread. Return to all comments →
A really small code for this problem. A hashmap would only increase the space complexity