Create a data structure to support the following operations. (s is a string consisting of only lowercase English alphabets and a is an integer) • Assign(s, a) : Assign string s a score of a (Update the score of s to a if already assigned something else) • Delete(s): Delete s and its score, if it exists • MaxScore() : Print the lexicographically smallest string with the maximum score followed by the maximum score, separated by a space. You can assume that whenever MaxScore() is queried, there is at least one string present. • GetScore(s) : Print the score assigned to the string s, if it exists, print 0 otherwise. Input First line of contains N, the number of queries in the test case, followed by N lines describing 1 query in each line. Each query line starts with a single capital letter describing the type of query followed by the arguments. • A' followed by string s and integer a => Assign(s, a) • 'D' followed by string s => Delete(s) 'M' => MaxScore() • 'G' followed by s => GetScore(s) Output • For every query of type MaxScore() and GetScore(), print the output of that query on separate line
Create a data structure to support the following operations. (s is a string consisting of only lowercase English alphabets and a is an integer) • Assign(s, a) : Assign string s a score of a (Update the score of s to a if already assigned something else) • Delete(s): Delete s and its score, if it exists • MaxScore() : Print the lexicographically smallest string with the maximum score followed by the maximum score, separated by a space. You can assume that whenever MaxScore() is queried, there is at least one string present. • GetScore(s) : Print the score assigned to the string s, if it exists, print 0 otherwise. Input First line of contains N, the number of queries in the test case, followed by N lines describing 1 query in each line. Each query line starts with a single capital letter describing the type of query followed by the arguments. • A' followed by string s and integer a => Assign(s, a) • 'D' followed by string s => Delete(s) 'M' => MaxScore() • 'G' followed by s => GetScore(s) Output • For every query of type MaxScore() and GetScore(), print the output of that query on separate line
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Please give a full detailed optimized solution in Java 8 for the given problem, use the example code provided as well. Please provide comments and screenshots of code and output. Also, add the time/space complexity and the reason for it.
Java 8 Code Example:
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String args[] ) throws Exception {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
}
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education