{ "data": { "question": { "questionId": "1136", "questionFrontendId": "1050", "boundTopicId": null, "title": "Actors and Directors Who Cooperated At Least Three Times", "titleSlug": "actors-and-directors-who-cooperated-at-least-three-times", "content": "
Table: ActorDirector
\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| actor_id | int |\n| director_id | int |\n| timestamp | int |\n+-------------+---------+\ntimestamp is the primary key (column with unique values) for this table.\n\n\n
\n\n
Write a solution to find all the pairs (actor_id, director_id)
where the actor has cooperated with the director at least three times.
Return the result table in any order.
\n\nThe result format is in the following example.
\n\n\n
Example 1:
\n\n\nInput: \nActorDirector table:\n+-------------+-------------+-------------+\n| actor_id | director_id | timestamp |\n+-------------+-------------+-------------+\n| 1 | 1 | 0 |\n| 1 | 1 | 1 |\n| 1 | 1 | 2 |\n| 1 | 2 | 3 |\n| 1 | 2 | 4 |\n| 2 | 1 | 5 |\n| 2 | 1 | 6 |\n+-------------+-------------+-------------+\nOutput: \n+-------------+-------------+\n| actor_id | director_id |\n+-------------+-------------+\n| 1 | 1 |\n+-------------+-------------+\nExplanation: The only pair is (1, 1) where they cooperated exactly 3 times.\n\n", "translatedTitle": null, "translatedContent": null, "isPaidOnly": false, "difficulty": "Easy", "likes": 617, "dislikes": 45, "isLiked": null, "similarQuestions": "[]", "exampleTestcases": "{\"headers\":{\"ActorDirector\":[\"actor_id\",\"director_id\",\"timestamp\"]},\"rows\":{\"ActorDirector\":[[1,1,0],[1,1,1],[1,1,2],[1,2,3],[1,2,4],[2,1,5],[2,1,6]]}}", "categoryTitle": "Database", "contributors": [], "topicTags": [ { "name": "Database", "slug": "database", "translatedName": null, "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": [ { "lang": "MySQL", "langSlug": "mysql", "code": "# Write your MySQL query statement below\n", "__typename": "CodeSnippetNode" }, { "lang": "MS SQL Server", "langSlug": "mssql", "code": "/* Write your T-SQL query statement below */\n", "__typename": "CodeSnippetNode" }, { "lang": "Oracle", "langSlug": "oraclesql", "code": "/* Write your PL/SQL query statement below */\n", "__typename": "CodeSnippetNode" }, { "lang": "Pandas", "langSlug": "pythondata", "code": "import pandas as pd\n\ndef actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame:\n ", "__typename": "CodeSnippetNode" }, { "lang": "PostgreSQL", "langSlug": "postgresql", "code": "-- Write your PostgreSQL query statement below\n", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"151.3K\", \"totalSubmission\": \"217.4K\", \"totalAcceptedRaw\": 151328, \"totalSubmissionRaw\": 217443, \"acRate\": \"69.6%\"}", "hints": [], "solution": { "id": "2013", "canSeeDetail": false, "paidOnly": true, "hasVideoSolution": false, "paidOnlyVideo": true, "__typename": "ArticleNode" }, "status": null, "sampleTestCase": "{\"headers\":{\"ActorDirector\":[\"actor_id\",\"director_id\",\"timestamp\"]},\"rows\":{\"ActorDirector\":[[1,1,0],[1,1,1],[1,1,2],[1,2,3],[1,2,4],[2,1,5],[2,1,6]]}}", "metaData": "{\"mysql\": [\"Create table If Not Exists ActorDirector (actor_id int, director_id int, timestamp int)\"], \"mssql\": [\"Create table ActorDirector (actor_id int, director_id int, timestamp int)\"], \"oraclesql\": [\"Create table ActorDirector (actor_id int, director_id int, timestamp int)\"], \"database\": true, \"name\": \"actors_and_directors\", \"pythondata\": [\"ActorDirector = pd.DataFrame([], columns=['actor_id', 'director_id', 'timestamp']).astype({'actor_id':'int64', 'director_id':'int64', 'timestamp':'int64'})\"], \"manual\": false, \"postgresql\": [\"Create table If Not Exists ActorDirector (actor_id int, director_id int, timestamp int)\"], \"database_schema\": {\"ActorDirector\": {\"actor_id\": \"INT\", \"director_id\": \"INT\", \"timestamp\": \"INT\"}}}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [ "Create table If Not Exists ActorDirector (actor_id int, director_id int, timestamp int)", "Truncate table ActorDirector", "insert into ActorDirector (actor_id, director_id, timestamp) values ('1', '1', '0')", "insert into ActorDirector (actor_id, director_id, timestamp) values ('1', '1', '1')", "insert into ActorDirector (actor_id, director_id, timestamp) values ('1', '1', '2')", "insert into ActorDirector (actor_id, director_id, timestamp) values ('1', '2', '3')", "insert into ActorDirector (actor_id, director_id, timestamp) values ('1', '2', '4')", "insert into ActorDirector (actor_id, director_id, timestamp) values ('2', '1', '5')", "insert into ActorDirector (actor_id, director_id, timestamp) values ('2', '1', '6')" ], "enableRunCode": true, "enableTestMode": false, "enableDebugger": false, "envInfo": "{\"mysql\": [\"MySQL\", \"
MySQL 8.0
.
mssql server 2019
.
Oracle Sql 11.2
.
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" } } }