You are appointed as the assistant to a teacher in a school and that teacher is correcting the answer sheets of the students. Each student can have multiple answer sheets. So the teacher has Q queries in below format:
1 student_name marks: Add the marks to the student whose name is student_name .
2 student_name: Erase the marks of the students whose name is student_name.
3 student_name: Print the marks of the students whose name is student_name. (If student_name didn't get any marks print 0.)
Copy from: https://www.hackerrank.com/challenges/cpp-maps/problem
Let me be lazy once. BTW, Hackerrank (https://www.hackerrank.com/) is a great website that helps you learning code. Go check it out.
The first line of the input contains Q where Q is the total number of queries. The next Q lines contain 1 query each. The first integer, type, of each query is the type of the query.
If type is 1, it consists of one string and an integer, student_name and marks where student_name is the name of the student and marks is the marks of the student.
If type is 2 or 3, it consists of a single string student_name where student_name is the name of the student.
For queries of type 3 print the marks of the given student.