欢迎来到代码驿站!

当前位置:首页 >

IDEA2020.1使用LeetCode插件运行并调试本地样例的方法详解

时间:2020-09-10 11:00:20|栏目:|点击:

环境: idea2020.1

插件: LeetCode-editor 6.7

一、IDEA安装LeetCode插件

在这里插入图片描述

安装完成重启idea

打开插件

在这里插入图片描述
在这里插入图片描述

URL可以选择国服和世界服。LoginName和Password填自己的用户名和密码即可。

需要配置的选项为:

TempFilePath: 自己保存代码的包的位置

CodeFileName:

$!velocityTool.camelCaseName(${question.titleSlug})

CodeTemplate:

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

配置完成后 刷新即可

输入代码测试运行提交

在这里插入图片描述

代码

package leetcode.editor.cn;

import java.util.Arrays;

//Java:两数之和
public class TwoSum {
 public static void main(String[] args) {
  Solution solution = new TwoSum().new Solution();
  // TO TEST
  int[] a ={1, 2, 3, 4};
  int[] ints = solution.twoSum(a, 3);
  System.out.println(Arrays.toString(ints));
 }
 class Solution {
  public int[] twoSum(int[] nums, int target) {
   for (int i = 0; i < nums.length; i++) {
    for (int j = i + 1; j < nums.length; j++) {
     if (nums[j] == target - nums[i]) {
      return new int[]{i, j};
     }
    }
   }
   throw new IllegalArgumentException("No two sum solution");
  }
 }
}

总结

上一篇:Mysql临时表及分区表区别详解

栏    目:

下一篇:R语言ggplot2边框背景去除的实现

本文标题:IDEA2020.1使用LeetCode插件运行并调试本地样例的方法详解

本文地址:http://www.codeinn.net/misctech/4777.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有