Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Map Problems For each of the Map problems, you ll be taking a Map as a parameter ( even if it doesn t show up
Map Problems
For each of the Map problems, youll be taking a Map as a parameter even if it doesnt show up in the method signature
contains
Implement a method that returns true if any string occurs at least times in the input list, and false otherwise. Use a map as auxiliary storage. For example, consider the following list:
is "fun", HI "fun", "fun"
contains should return true given this input because fun shows up at least times.
intersect
Implement a method that takes as input two maps from Strings to Integers and returns a new map whose contents are the intersection of the two. The intersection of two maps is defined here as the set of keysvalue pairs that exist in both maps. If some key K maps to value V in both the first and second map, include it in your result. If K does not exist as a key in both maps, or if K does not map to the same value V in both maps, exclude that pair from your result.
For example, consider the following two maps:
map: Janet Logan Whitaker Alyssa Stefanie Jeff Kim Sylvia
map: Logan Kim Whitaker Jeff Stefanie Brian Lisa Sylvia
Calling intersectmap map would return the following new map the order of the keyvalue pairs does not matter:
Logan Stefanie Jeff Kim
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