Question
You are supposed to complete the following functions :- map createMap(string[],int); bool isPresent(map , string); The first method takes an array of strings and the
You are supposed to complete the following functions :-
map> createMap(string[],int); bool isPresent(map >, string);
The first method takes an array of strings and the length of that array and creates a map with the key - String Length and value is pushed into a Stack of strings. This time the strings can be of same length. It returns the map created with all lengths as keys and all strings in stacks of the respective keys. You have to use the Stack implementation of Standard Template Library.
Ex.
Input - ["Hello", "Aman", "Preet"] , 3
Output - [{4:"Aman"}, {5:("Hello", "Preet") }]
The second method takes a map and a string and checks if the given string is present in the map you created.
Ex. Input - [{4:"Aman"}, {5:("Hello", "Preet") }], "Hello"]
Output- 1
Input - Contains strings that are used to create map
Output - We will test all strings by hashing different lengths and then we also test your isPresent function
Sample Input 1:
Apple Microsoft Google Facebook Netflix Rat Maple
Sample Output 1:
Rat 1
Sample Input 2:
Apple Microsoft Google Facebook Netflix Rat
Sample Output 2:
Rat 1
//Template
map
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started