I’m not sure how many people in this sub use Python, but I wanted to share this program because it allowed me to practice all 125 LeetCode (LC) database/SQL problems in an efficient way.
Background- the two problem I wanted to solve:
-
Majority of SQL problems on LC are locked
-
Even with access to the problem, creating the query can be challenging without being able to test and output the intermediate queries that make up the final solution.
My initial solution was manually copying and pasting the tables from LC to db-fiddle.com, but then I thought, there must be a better way- that is how this program was conceived.
What this Python program does:
Using the web automation package Selenium, it opens the LC problem selected by the user, parses the table data, and creates the table schema in db-fiddle so that you can test your queries. Additionally, it saves all the db-fiddles you've been working on in case you want to continue working on them in future sessions.
Sample outputs (for question #1369):
problem statement tab: https://leetcode.jp/problemdetail.php?id=1369
db-fiddle tab: https://www.db-fiddle.com/f/oMDnFch8BXL45r3dUVF17V/0
solutions tab: https://github.com/kamyu104/LeetCode-Solutions/blob/master/MySQL/get-the-second-most-recent-activity.sql
Demo and GitHub link:
Check it out on GitHub: https://github.com/jjjchens235/leetcode-sql-unlocked
Not to be a spoil sport, but it could probably be construed as copyright infringement.
Just thought I'd mention it in case you're concerned about that sort of thing.
I was browsing leetcode sql problems 10 seconds ago and was thinking like most of them are locked and this post popped up.