Sort by

recency

|

2762 Discussions

|

  • + 0 comments

    simple cpp solutions

    int designerPdfViewer(vector h, string word) {

    int maxheight=0;
    

    for(char c :word){ int a= c -'a'; maxheight=max(maxheight,h[a]); } int area=maxheight * word.length(); return area; }

  • + 0 comments

    Just finished helping my kid set up his new kids airbed for a sleepover! While I was at it, I stumbled upon this PDF highlighter problem—kinda fun figuring out the highlighted area based on letter heights. It’s like measuring how tall his alphabet blocks would stack up, but with numbers. The kids airbed is ready, and now I’ve got coding puzzles to keep me busy too—win-win! 😄

    (Your problem's solution is simple: find the tallest letter in the word using the given heights, then multiply that height by the word's length—since each letter is 1 unit wide. Easy peasy!)

  • + 0 comments
    public static int designerPdfViewer(List<Integer> h, String word) {
        char start = 'a';
        int end = start+26;
        Map<Character, Integer> map = new LinkedHashMap<>();
        for(int i=start, j=0; i<=end && j<h.size(); i++, j++) {
            map.put((char)i, h.get(j));
        }
        int maxHeight = Arrays.stream(word.split("")).mapToInt(s -> {
            Character c = s.charAt(0);
            return map.get(c);
        }).max().orElse(0);
        return maxHeight * word.length();
    }
    
  • + 0 comments

    List alphabet = new ArrayList<>();

        for(int i=0;i<26;i++){
            alphabet.add((char)('a'+i));
        }
        int index=0;
        List<Integer> addIndexes = new ArrayList<>();
        for(int i=0; i<word.length();i++){
            char charletter = word.charAt(i);
            index = alphabet.indexOf(charletter);
            addIndexes.add(h.get(index));
    
            }
            return word.length()*Collections.max(addIndexes);
    
  • + 0 comments

    I was solving the designerPdfViewer problem for calculating highlighted area based on letter heights, and it reminded me how important details are—just like choosing the perfect scent. If you’re into oud perfumes, check out https://bossonwheels.com/collections/oud for some amazing options that stand out just like the tallest letter in that problem.