subject
Computers and Technology, 24.09.2020 14:01 mxwtwo

You've created a new programming language, and now you've decided to add hashmap support to it. Actually you are quite disappointed that in common programming languages it's impossible to add a number to all hashmap keys, or all its values. So you've decided to take matters into your own hands and implement your own hashmap in your new language that has the following operations:insert x y - insert an object with key x and value y. get x - return the value of an object with key x. addToKey x - add x to all keys in map. addToValue y - add y to all values in map. To test out your new hashmap, you have a list of queries in the form of two arrays: queryTypes contains the names of the methods to be called (eg: insert, get, etc), and queries contains the arguments for those methods (the x and y values).Your task is to implement this hashmap, apply the given queries, and to find the sum of all the results for get operations. ExampleFor queryType = ["insert", "insert", "addToValue", "addToKey", "get"] and query = [[1, 2], [2, 3], [2], [1], [3]], the output should be hashMap(queryType, query) = 5.The hashmap looks like this after each query:1 query: {1: 2}2 query: {1: 2, 2: 3}3 query: {1: 4, 2: 5}4 query: {2: 4, 3: 5}5 query: answer is 5The result of the last get query for 3 is 5 in the resulting hashmap. For queryType = ["insert", "addToValue", "get", "insert", "addToKey", "addToValue", "get"] and query = [[1, 2], [2], [1], [2, 3], [1], [-1], [3]], the output should be hashMap(queryType, query) = 6.The hashmap looks like this after each query:1 query: {1: 2}2 query: {1: 4}3 query: answer is 44 query: {1: 4, 2: 3}5 query: {2: 4, 3: 3}6 query: {2: 3, 3: 2}7 query: answer is 2The sum of the results for all the get queries is equal to 4 + 2 = 6.Input/Output[execution time limit] 4 seconds (py3)[input] array. string queryTypeArray of query types. It is guaranteed that each queryType[i] is either "addToKey", "addToValue", "get", or "insert".Guaranteed constraints:1 ≤ queryType. length ≤ 105.[input] array. array. integer queryArray of queries, where each query is represented either by two numbers for insert query or by one number for other queries. It is guaranteed that during all queries all keys and values are in the range [-109, 109].Guaranteed constraints:query. length = queryType. length,1 ≤ query[i].length ≤ 2.[output] integer64The sum of the results for all get queries.[Python3] Syntax Tips# Prints help message to the console# Returns a stringdef helloWorld(name):print("This prints to the console when you Run Tests")return "Hello, " + name

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:00
Signal sets company contracts to deliver one hundred 52-inch plasma high-definition television sets to a new retail customer, tuner tv store, on may 1, with payment to be made on delivery. signal tenders delivery in its own truck. tuner's manager notices that some of the cartons have scrape marks. tuner's owner phones signal's office and asks whether the sets might have been damaged as they were being loaded. signal assures tuner that the sets are in perfect condition. tuner tenders signal a check, which signal refuses, claiming that the first delivery to new customers is always for cash. tuner promises to pay the cash within two days. signal leaves the sets with tuner, which stores them in its warehouse pending its "grand opening sale" on may 15. two days later, tuner's stocker opens some of the cartons and discovers that a number of the sets are damaged beyond ordinary repair. signal claims tuner has accepted the sets and is in breach by not paying on delivery. will signal succeed on these claims? explain.
Answers: 1
question
Computers and Technology, 22.06.2019 01:00
Which option marks all modification made within a document? review comment track changes balloons
Answers: 1
question
Computers and Technology, 22.06.2019 21:00
Which of these is most responsible for differences between the twentieth century to the twenty-first century?
Answers: 2
question
Computers and Technology, 22.06.2019 22:40
In this lab, you complete a python program that calculates an employee's annual bonus. input is an employee's first name, last name, salary, and numeric performance rating. if the rating is 1, 2, or 3, the bonus rate used is .25, .15, or .1 respectively. if the rating is 4 or higher, the rate is 0. the employee bonus is calculated by multiplying the bonus rate by the annual salary.
Answers: 1
You know the right answer?
You've created a new programming language, and now you've decided to add hashmap support to it. Actu...
Questions
question
Physics, 10.03.2020 09:13
Questions on the website: 13722367