๐–๐ก๐š๐ญ ๐ก๐š๐ฉ๐ฉ๐ž๐ง๐ฌ ๐š๐Ÿ๐ญ๐ž๐ซ ๐ฌ๐ฎ๐›๐ฆ๐ข๐ญ๐ญ๐ข๐ง๐  ๐ฒ๐จ๐ฎ๐ซ ๐œ๐จ๐๐ž ๐จ๐ง HackerRank and LeetCode ๐ฐ๐จ๐ซ๐ค ๐จ๐ง ๐ญ๐ก๐ž ๐›๐š๐œ๐ค๐ž๐ง๐?

Photo by Andrew Neel on Unsplash

๐–๐ก๐š๐ญ ๐ก๐š๐ฉ๐ฉ๐ž๐ง๐ฌ ๐š๐Ÿ๐ญ๐ž๐ซ ๐ฌ๐ฎ๐›๐ฆ๐ข๐ญ๐ญ๐ข๐ง๐  ๐ฒ๐จ๐ฎ๐ซ ๐œ๐จ๐๐ž ๐จ๐ง HackerRank and LeetCode ๐ฐ๐จ๐ซ๐ค ๐จ๐ง ๐ญ๐ก๐ž ๐›๐š๐œ๐ค๐ž๐ง๐?

ยท

2 min read

Though there is NO official blog available for this, still I tried to attach the resources from different sites.

  1. When you click the "run" button on the website, an API request is sent to the back-end containing your code (along with other relevant information such as your user ID and the ID of the problem being solved).

2)When the server receives the request, several things happen. The server compiles your code (or tries to, if you're using a compiled language).

  1. The server then executes the resulting program. I'm assuming it'll be run inside a container (e.g. Docker). This is due to a number of factors. First, the amount of memory and other resources available to your program can be precisely controlled.
    ๐’๐ž๐œ๐จ๐ง๐, to precisely control the environment in which it runs; for example, Java programs, will launch a container from an image that only contains the bare minimum Java runtime and nothing else.
    ๐“๐ก๐ข๐ซ๐, to make it simple to set a timeout, i.e. simply kill the container if it does not complete running within the time limit.

๐…๐จ๐ฎ๐ซ๐ญ๐ก, and most importantly, for security. Using a container makes it simple to ensure that the program does not interact with anything other than the standard I/O (stdin, stdout, stderr) used to test your program. For example, your program may be unable to access the network or filesystem because the container does not explicitly permit it.
Once your program's container (or, more likely, one container for each test case) is running, the data for that test case is sent to that container's STDIN. The system then reads the STDOUT and compares it to the expected output of the program. If there is an exact match, the test case passes. Otherwise, if there is no exact match, the test times out, or a runtime error occurs, then the test case fails.

  1. The results of the test are saved and sent back to the user.

๐€ ๐ƒ๐’๐€ ๐ช๐ฎ๐ž๐ฌ๐ญ๐ข๐จ๐ง ๐š ๐๐š๐ฒ ๐ค๐ž๐ž๐ฉ๐ฌ ๐ญ๐ก๐ž ๐ˆ๐ง๐ญ๐ž๐ซ๐ฏ๐ข๐ž๐ฐ ๐…๐ž๐š๐ซ ๐š๐ฐ๐š๐ฒ

Did you find this article valuable?

Support Ridhi Singla by becoming a sponsor. Any amount is appreciated!

ย