• 请不要在回答技术问题时复制粘贴 AI 生成的内容
ericgui
V2EX  ›  程序员

leetcode 具体是怎么运行你的代码片段的?

  •  
  •   ericgui · Jan 5, 2022 · 3362 views
    This topic created in 1611 days ago, the information mentioned may be changed or developed.

    比如某一个题,你写了一个函数,提交了,运行结果你通过了

    这个在 leetcode 后台具体是怎么实现的?你传过去的是一个大大长长的字符串,然后他们要把这个字符串写入某个文件,比如 py 文件,比如 Java 文件,比如 js 文件

    然后有一个外部的函数来调用这个文件里的函数?

    后台用什么运行? docker ?

    6 replies    2022-01-06 13:49:12 +08:00
    Mutoo
        1
    Mutoo  
       Jan 5, 2022 via iPhone
    https://github.com/zhblue/hustoj
    可以参考开源 oj 本质就是在一个受限环境编译运行你的代码,跑测试数据并统计结果。
    mrlmh00
        2
    mrlmh00  
       Jan 5, 2022
    你看看开源的 oj 怎么实现的呗
    https://github.com/zhblue/hustoj
    mrlmh00
        3
    mrlmh00  
       Jan 5, 2022
    @Mutoo 卧槽巧了。。我发完了刷新出来你的
    zouzou0208
        4
    zouzou0208  
       Jan 5, 2022 via iPhone   ❤️ 1
    恰好我完整的研究过,可以参考我这篇文章

    力扣的程序是如何运行的:
    https://github.com/yihong0618/gitblog/issues/205
    zouzou0208
        5
    zouzou0208  
       Jan 5, 2022 via iPhone
    是 docker 运行,但做了安全保护,无法逃逸。这篇文章写了 python 的,关于其它语言可以用这个方式自己研究。
    constructor
        6
    constructor  
       Jan 6, 2022
    前几天对 replit 运行代码研究过:使用 docker 运行单个代码文件或项目,
    https://v2ex.com/t/821487#r_11174090
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3641 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 10:30 · PVG 18:30 · LAX 03:30 · JFK 06:30
    ♥ Do have faith in what you're doing.