File tree 2 files changed +40
-1
lines changed
2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ I have also solved other domains on HackerRank that can be viewed at:
92
92
| [ Picking Numbers] ( https://www.hackerrank.com/challenges/picking-numbers ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( https://github.com/anishLearnsToCode/hackerrank-algorithms/blob/master/src/implimentation/PickingNumbers.java ) |
93
93
| [ Climbing The Leaderboard] ( https://www.hackerrank.com/challenges/climbing-the-leaderboard ) | Medium | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( https://github.com/anishLearnsToCode/hackerrank-algorithms/blob/master/src/implimentation/ClimbingTheLeaderboard.java ) |
94
94
| [ The Hurdle Race] ( https://www.hackerrank.com/challenges/the-hurdle-race ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( https://github.com/anishLearnsToCode/hackerrank-algorithms/blob/master/src/implimentation/TheHurdleRace.java ) |
95
- | [ Designer PDF Viwer ] ( https://www.hackerrank.com/challenges/designer-pdf-viewer ) | Easy | |
95
+ | [ Designer PDF Viewer ] ( https://www.hackerrank.com/challenges/designer-pdf-viewer ) | Easy | |
96
96
| [ Utopian Tree] ( https://www.hackerrank.com/challenges/utopian-tree ) | Easy | |
97
97
| [ Angry Professor] ( https://www.hackerrank.com/challenges/angry-professor ) | Easy | |
98
98
| [ Beautiful Days at the movies] ( https://www.hackerrank.com/challenges/beautiful-days-at-the-movies ) | Easy | |
Original file line number Diff line number Diff line change
1
+ // https://www.hackerrank.com/challenges/designer-pdf-viewer/problem
2
+
3
+ package implimentation ;
4
+
5
+ import java .util .HashMap ;
6
+ import java .util .Map ;
7
+ import java .util .Scanner ;
8
+
9
+ public class DesignerPdfViewer {
10
+ private static final Scanner scanner = new Scanner (System .in );
11
+
12
+ public static void main (String [] args ) {
13
+ Map <Character , Integer > alphabetHeights = getAlphabetHeights ();
14
+ String word = scanner .next ();
15
+ System .out .println (area (word , alphabetHeights ));
16
+ }
17
+
18
+ private static int area (String word , Map <Character , Integer > alphabetHeights ) {
19
+ int maxHeight = getMaxHeight (word , alphabetHeights );
20
+ return maxHeight * word .length ();
21
+ }
22
+
23
+ private static int getMaxHeight (String word , Map <Character , Integer > heights ) {
24
+ int result = 0 ;
25
+ for (int index = 0 ; index < word .length () ; index ++) {
26
+ char character = word .charAt (index );
27
+ result = Math .max (result , heights .get (character ));
28
+ }
29
+ return result ;
30
+ }
31
+
32
+ private static Map <Character , Integer > getAlphabetHeights () {
33
+ Map <Character , Integer > heights = new HashMap <>();
34
+ for (char character = 'a' ; character <= 'z' ; character ++) {
35
+ heights .put (character , scanner .nextInt ());
36
+ }
37
+ return heights ;
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments