如何优雅地用IDEA刷LeetCode

  1. 点击右上角文件->设置->Plugins,搜索leetcode,找到leetcode editor并安装,如下图:

    image-20210415210517555

  2. 在IDEA右侧边点击leetcode,打开插件主界面后打开设置:

    image-20210415211241139

  3. CodeFileName处填:

    1
    P$!{question.frontendQuestionId}$!velocityTool.camelCaseName(${question.titleSlug}) 

    CodeTemplate处填:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    ${question.content}

    package leetcode.editor.cn; // 此处不要改
    //Java:${question.title}
    public class P${question.frontendQuestionId}$!velocityTool.camelCaseName(${question.titleSlug}){
    public static void main(String[] args) {
    Solution solution = new P$!{question.frontendQuestionId}$!velocityTool.camelCaseName(${question.titleSlug})().new Solution();
    // TO TEST
    }
    ${question.code}
    }

    填完之后点应用,确定。

  4. 然后点如下操作:

    image-20210415211744092

  5. 大功告成,去刷题吧。