Create Your Own LeetCode with Judge0

๐Ÿ’ป Create Your Own LeetCode with Judge๐Ÿ”ฅ

What is Judge0?

Judge0 is an open-source online code execution engine that supports over 60 programming languages. It allows you to compile and run code remotely via a REST API, making it perfect for building coding platforms, online judges, or interview preparation tools like LeetCode, HackerRank, or Codeforces. Whether you're running C++, Python, JavaScript, or Go โ€” Judge0 handles it all in a secure, sandboxed environment.

How to Setup Judge0?

I recommend using Linux especially Ubuntu-20.04, but you can also setup this on Mac.

For Windows Users Special Steps

Install WSL in your Windows, run this command in your PowerShell terminal:

Installing WSL

wsl --install

Then setup your Unix username and password. After this restart your PC then run this command to install Ubuntu-20.04:

wsl --install -d Ubuntu-20.04

Then login to Ubuntu with this command:

wsl -d Ubuntu-20.04

Your terminal will change like this:

WSL Terminal

Then run command:

sudo apt update
# Enter the password which you set in the Unix login

After this:

sudo apt upgrade
sudo reboot

After rebooting the Ubuntu it will be closed so then restart with:

wsl -d Ubuntu-20.04

Then again it will be like this:

WSL Terminal After Reboot

Then run again:

sudo apt update 
# Enter the password

Then open the grub file in nano with command:

โœ… Fixing GRUB Syntax Error in Ubuntu

๐Ÿ”ง Step 1: Open the GRUB config file

sudo nano /etc/default/grub

It'll ask for your password โ€” type it and press Enter.

๐Ÿงพ Step 2: Paste the following into the file

Note: (if you have empty grub file then do this if not paste only last line):

GRUB_DEFAULT=0
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=systemd.unified_cgroup_hierarchy=0
  • Use Ctrl + Shift + V to paste (if you're on a standard terminal).
  • Make sure there are no extra characters or spaces after any line.

๐Ÿ’พ Step 3: Save and Exit

  • Press Ctrl + O (to write/save the file)
  • Press Enter (to confirm)
  • Press Ctrl + X (to exit the editor)

๐Ÿ”„ Step 4: Update GRUB

sudo update-grub

๐Ÿ“‹ If a popup appears, select the 2nd option (usually your system disk), then press OK.
If no popup, it will just update silently โ€” that's fine too.

โœ… Step 5: Reconfigure and clean up

Run this to finish up:

sudo dpkg --configure -a
sudo apt install -f

This should fix the broken grub-pc and grub-gfxpayload-lists issues.

After this everything is on Judge0 GitHub documentation link: https://github.com/judge0/judge0/blob/master/CHANGELOG.md

But here's simple steps to do it:

Download Docker and Docker-compose with this command:

sudo apt install docker
# This will install Docker
sudo apt install docker-compose
# This will install Docker-compose

Getting Judge0 File

Note: Mac users can follow this from here

wget https://github.com/judge0/judge0/releases/download/v1.13.1/judge0-v1.13.1.zip

Installing Unzip

sudo apt install unzip
# This will install unzip

Unzip the Judge0 file

unzip judge0-v1.13.1.zip

Setting Up Password

Then go to Judge0 file with cd command:

cd judge0-v1.13.1/
ls 
# ls will show you these files docker-compose.yml  judge0.conf

Then set the REDIS_PASSWORD and POSTGRES_PASSWORD and judge0.conf of your choice.

I recommend using this website to generate passwords.

sudo nano judge0.conf
# Then set the password
  • Press Ctrl + O (to write/save the file)
  • Press Enter (to confirm)
  • Press Ctrl + X (to exit the editor)

Running DB and Docker

After lets run db and redis this will take time:

sudo docker-compose up -d db redis
sleep 10s
sudo docker-compose up -d
sleep 5s

Then check if containers are running or not with command:

sudo docker-compose ps
# It will show the four status are up

Docker Containers Status

Then go to http://localhost:2358/docs if it's open your setup done and you can go to http://localhost:2358/dummy-client.html to run the code.

For Restarting the Program

If you want to start the setup just run these command in Windows terminal:

# Mac and Linux users skip WSL command
wsl -d Ubuntu-20.04
sudo docker-compose up -d 
# It will run everything again

Note: For Mac users if it's not working for Mac users simply setup a virtual box machine with Linux or purchase a machine online for more information follow instructions from Hitesh sir video https://youtu.be/6nkNUDNhSYI?si=OvVQuFpqN13PQ5kV


๐ŸŽฏ Conclusion

Now you have your own Judge0 setup running locally! You can build your own coding platform, create online judges, or develop interview preparation tools. The Judge0 API gives you the power to execute code in over 60 programming languages securely.

Happy coding! ๐Ÿš€

Built with love by Sujal Patel