{ "data": { "question": { "questionId": "3503", "questionFrontendId": "3188", "boundTopicId": null, "title": "Find Top Scoring Students II", "titleSlug": "find-top-scoring-students-ii", "content": null, "translatedTitle": null, "translatedContent": null, "isPaidOnly": true, "difficulty": "Hard", "likes": 4, "dislikes": 2, "isLiked": null, "similarQuestions": "[]", "exampleTestcases": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"major\"],\"courses\":[\"course_id\",\"name\",\"credits\",\"major\",\"mandatory\"],\"enrollments\":[\"student_id\",\"course_id\",\"semester\",\"grade\",\"GPA\"]},\"rows\":{\"students\":[[1,\"Alice\",\"Computer Science\"],[2,\"Bob\",\"Computer Science\"],[3,\"Charlie\",\"Mathematics\"],[4,\"David\",\"Mathematics\"]],\"courses\":[[101,\"Algorithms\",3,\"Computer Science\",\"Yes\"],[102,\"Data Structures\",3,\"Computer Science\",\"Yes\"],[103,\"Calculus\",4,\"Mathematics\",\"Yes\"],[104,\"Linear Algebra\",4,\"Mathematics\",\"Yes\"],[105,\"Machine Learning\",3,\"Computer Science\",\"No\"],[106,\"Probability\",3,\"Mathematics\",\"No\"],[107,\"Operating Systems\",3,\"Computer Science\",\"No\"],[108,\"Statistics\",3,\"Mathematics\",\"No\"]],\"enrollments\":[[1,101,\"Fall 2023\",\"A\",4.0],[1,102,\"Spring 2023\",\"A\",4.0],[1,105,\"Spring 2023\",\"A\",4.0],[1,107,\"Fall 2023\",\"B\",3.5],[2,101,\"Fall 2023\",\"A\",4.0],[2,102,\"Spring 2023\",\"B\",3.0],[3,103,\"Fall 2023\",\"A\",4.0],[3,104,\"Spring 2023\",\"A\",4.0],[3,106,\"Spring 2023\",\"A\",4.0],[3,108,\"Fall 2023\",\"B\",3.5],[4,103,\"Fall 2023\",\"B\",3.0],[4,104,\"Spring 2023\",\"B\",3.0]]}}", "categoryTitle": "Database", "contributors": [], "topicTags": [ { "name": "Database", "slug": "database", "translatedName": null, "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": null, "stats": "{\"totalAccepted\": \"180\", \"totalSubmission\": \"327\", \"totalAcceptedRaw\": 180, \"totalSubmissionRaw\": 327, \"acRate\": \"55.0%\"}", "hints": [], "solution": null, "status": null, "sampleTestCase": "{\"headers\":{\"students\":[\"student_id\",\"name\",\"major\"],\"courses\":[\"course_id\",\"name\",\"credits\",\"major\",\"mandatory\"],\"enrollments\":[\"student_id\",\"course_id\",\"semester\",\"grade\",\"GPA\"]},\"rows\":{\"students\":[[1,\"Alice\",\"Computer Science\"],[2,\"Bob\",\"Computer Science\"],[3,\"Charlie\",\"Mathematics\"],[4,\"David\",\"Mathematics\"]],\"courses\":[[101,\"Algorithms\",3,\"Computer Science\",\"Yes\"],[102,\"Data Structures\",3,\"Computer Science\",\"Yes\"],[103,\"Calculus\",4,\"Mathematics\",\"Yes\"],[104,\"Linear Algebra\",4,\"Mathematics\",\"Yes\"],[105,\"Machine Learning\",3,\"Computer Science\",\"No\"],[106,\"Probability\",3,\"Mathematics\",\"No\"],[107,\"Operating Systems\",3,\"Computer Science\",\"No\"],[108,\"Statistics\",3,\"Mathematics\",\"No\"]],\"enrollments\":[[1,101,\"Fall 2023\",\"A\",4.0],[1,102,\"Spring 2023\",\"A\",4.0],[1,105,\"Spring 2023\",\"A\",4.0],[1,107,\"Fall 2023\",\"B\",3.5],[2,101,\"Fall 2023\",\"A\",4.0],[2,102,\"Spring 2023\",\"B\",3.0],[3,103,\"Fall 2023\",\"A\",4.0],[3,104,\"Spring 2023\",\"A\",4.0],[3,106,\"Spring 2023\",\"A\",4.0],[3,108,\"Fall 2023\",\"B\",3.5],[4,103,\"Fall 2023\",\"B\",3.0],[4,104,\"Spring 2023\",\"B\",3.0]]}}", "metaData": "{\"mysql\": [\"CREATE TABLE if not exists students (\\n student_id INT ,\\n name VARCHAR(255),\\n major VARCHAR(255)\\n)\", \"CREATE TABLE if not exists courses (\\n course_id INT ,\\n name VARCHAR(255),\\n credits INT,\\n major VARCHAR(255),\\n mandatory ENUM('yes', 'no') DEFAULT 'no'\\n)\", \"CREATE TABLE if not exists enrollments (\\n student_id INT,\\n course_id INT,\\n semester VARCHAR(255),\\n grade VARCHAR(10),\\nGPA decimal(3,2)\\n\\n);\"], \"mssql\": [\"CREATE TABLE students (\\n student_id INT ,\\n name VARCHAR(255),\\n major VARCHAR(255)\\n)\", \"CREATE TABLE courses (\\n course_id INT PRIMARY KEY,\\n name VARCHAR(255),\\n credits INT,\\n major VARCHAR(255),\\n mandatory VARCHAR(3) CHECK (mandatory IN ('yes', 'no')) DEFAULT 'no'\\n)\", \"CREATE TABLE enrollments (\\n student_id INT,\\n course_id INT,\\n semester VARCHAR(255),\\n grade VARCHAR(1),\\n GPA DECIMAL(3,2)\\n)\"], \"oraclesql\": [\"CREATE TABLE students (\\n student_id NUMBER ,\\n name VARCHAR2(255),\\n major VARCHAR2(255)\\n)\", \"CREATE TABLE courses (\\n course_id NUMBER ,\\n name VARCHAR2(255),\\n credits NUMBER,\\n major VARCHAR2(255),\\n mandatory VARCHAR2(3) CHECK (mandatory IN ('Yes', 'No')) \\n)\", \"CREATE TABLE enrollments (\\n student_id NUMBER,\\n course_id NUMBER,\\n semester VARCHAR2(255),\\n grade VARCHAR2(1),\\n GPA Number (3,2)\\n)\"], \"database\": true, \"name\": \"find_top_scoring_students\", \"pythondata\": [\"students = pd.DataFrame([], columns=['student_id', 'name', 'major']).astype({\\n 'student_id': 'Int64', # Nullable integer type for student_id\\n 'name': 'string', # String type for names\\n 'major': 'string' # String type for majors\\n})\", \"courses = pd.DataFrame([], columns=['course_id', 'name', 'credits', 'major', 'mandatory']).astype({'course_id': 'Int64', 'name': 'string', 'credits': 'Int64', 'major': 'string', 'mandatory': 'string'})\\n\\n # pd.CategoricalDtype(categories=['yes', 'no'])\\n\", \"enrollments = pd.DataFrame([], columns=['student_id', 'course_id', 'semester', 'grade', 'GPA']).astype({'student_id': 'Int64', 'course_id': 'Int64', 'semester': 'string', 'grade': 'string', 'GPA': 'float'})\\n\"], \"postgresql\": [\"CREATE TABLE IF NOT EXISTS students (\\n student_id SERIAL,\\n name VARCHAR(255),\\n major VARCHAR(255)\\n);\", \"CREATE TABLE courses (\\n course_id INTEGER, -- or SERIAL if you want auto-increment\\n name VARCHAR(255),\\n credits INTEGER, -- or NUMERIC if you need decimal places\\n major VARCHAR(255),\\n mandatory VARCHAR(3) CHECK (mandatory IN ('Yes', 'No'))\\n);\\n\", \"CREATE TABLE IF NOT EXISTS enrollments (\\n student_id INT,\\n course_id INT,\\n semester VARCHAR(255),\\n grade VARCHAR(10),\\n GPA NUMERIC(3,2)\\n);\\n\"], \"database_schema\": {\"students\": {\"student_id\": \"INT\", \"name\": \"VARCHAR(255)\", \"major\": \"VARCHAR(255)\"}, \"courses\": {\"course_id\": \"INT\", \"name\": \"VARCHAR(255)\", \"credits\": \"INT\", \"major\": \"VARCHAR(255)\", \"mandatory\": \"ENUM('yes', 'no')\"}, \"enrollments\": {\"student_id\": \"INT\", \"course_id\": \"INT\", \"semester\": \"VARCHAR(255)\", \"grade\": \"VARCHAR(10)\", \"GPA\": \"DECIMAL(3, 2)\"}}}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [ "CREATE TABLE if not exists students (\n student_id INT ,\n name VARCHAR(255),\n major VARCHAR(255)\n)", "CREATE TABLE if not exists courses (\n course_id INT ,\n name VARCHAR(255),\n credits INT,\n major VARCHAR(255),\n mandatory ENUM('yes', 'no') DEFAULT 'no'\n)", "CREATE TABLE if not exists enrollments (\n student_id INT,\n course_id INT,\n semester VARCHAR(255),\n grade VARCHAR(10),\nGPA decimal(3,2)\n\n);", "Truncate table students", "insert into students (student_id, name, major) values ('1', 'Alice', 'Computer Science')", "insert into students (student_id, name, major) values ('2', 'Bob', 'Computer Science')", "insert into students (student_id, name, major) values ('3', 'Charlie', 'Mathematics')", "insert into students (student_id, name, major) values ('4', 'David', 'Mathematics')", "Truncate table courses", "insert into courses (course_id, name, credits, major, mandatory) values ('101', 'Algorithms', '3', 'Computer Science', 'Yes')", "insert into courses (course_id, name, credits, major, mandatory) values ('102', 'Data Structures', '3', 'Computer Science', 'Yes')", "insert into courses (course_id, name, credits, major, mandatory) values ('103', 'Calculus', '4', 'Mathematics', 'Yes')", "insert into courses (course_id, name, credits, major, mandatory) values ('104', 'Linear Algebra', '4', 'Mathematics', 'Yes')", "insert into courses (course_id, name, credits, major, mandatory) values ('105', 'Machine Learning', '3', 'Computer Science', 'No')", "insert into courses (course_id, name, credits, major, mandatory) values ('106', 'Probability', '3', 'Mathematics', 'No')", "insert into courses (course_id, name, credits, major, mandatory) values ('107', 'Operating Systems', '3', 'Computer Science', 'No')", "insert into courses (course_id, name, credits, major, mandatory) values ('108', 'Statistics', '3', 'Mathematics', 'No')", "Truncate table enrollments", "insert into enrollments (student_id, course_id, semester, grade, GPA) values ('1', '101', 'Fall 2023', 'A', '4.0')", "insert into enrollments (student_id, course_id, semester, grade, GPA) values ('1', '102', 'Spring 2023', 'A', '4.0')", "insert into enrollments (student_id, course_id, semester, grade, GPA) values ('1', '105', 'Spring 2023', 'A', '4.0')", "insert into enrollments (student_id, course_id, semester, grade, GPA) values ('1', '107', 'Fall 2023', 'B', '3.5')", "insert into enrollments (student_id, course_id, semester, grade, GPA) values ('2', '101', 'Fall 2023', 'A', '4.0')", "insert into enrollments (student_id, course_id, semester, grade, GPA) values ('2', '102', 'Spring 2023', 'B', '3.0')", "insert into enrollments (student_id, course_id, semester, grade, GPA) values ('3', '103', 'Fall 2023', 'A', '4.0')", "insert into enrollments (student_id, course_id, semester, grade, GPA) values ('3', '104', 'Spring 2023', 'A', '4.0')", "insert into enrollments (student_id, course_id, semester, grade, GPA) values ('3', '106', 'Spring 2023', 'A', '4.0')", "insert into enrollments (student_id, course_id, semester, grade, GPA) values ('3', '108', 'Fall 2023', 'B', '3.5')", "insert into enrollments (student_id, course_id, semester, grade, GPA) values ('4', '103', 'Fall 2023', 'B', '3.0')", "insert into enrollments (student_id, course_id, semester, grade, GPA) values ('4', '104', 'Spring 2023', 'B', '3.0')" ], "enableRunCode": true, "enableTestMode": false, "enableDebugger": false, "envInfo": "{\"mysql\": [\"MySQL\", \"

MySQL 8.0.

\"], \"mssql\": [\"MS SQL Server\", \"

mssql server 2019.

\"], \"oraclesql\": [\"Oracle\", \"

Oracle Sql 11.2.

\"], \"pythondata\": [\"Pandas\", \"

Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0

\"], \"postgresql\": [\"PostgreSQL\", \"

PostgreSQL 16

\"]}", "libraryUrl": null, "adminUrl": null, "challengeQuestion": null, "__typename": "QuestionNode" } } }