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

作者:Old丶x 时间:2022-02-28 09:44:47 

环境: idea2020.1

插件: LeetCode-editor 6.7

一、IDEA安装LeetCode插件

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

安装完成重启idea

打开插件

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

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}
}

配置完成后 刷新即可

输入代码测试运行提交

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

代码


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");
 }
}
}

来源:https://blog.csdn.net/qq_41316955/article/details/108406931

标签:IDEA,LeetCode,插件
0
投稿

猜你喜欢

  • 判断图片-判断位图是否是黑白图片的方法

    2023-06-09 17:20:07
  • java property配置文件管理工具框架过程详解

    2023-10-12 04:35:50
  • Java设计模式编程中的工厂方法模式和抽象工厂模式

    2023-03-19 05:50:48
  • 关于Scanner对象的输入结束标记问题

    2022-02-20 08:02:11
  • Spring整合Mybatis思路梳理总结

    2022-04-26 03:56:12
  • Java 添加超链接到 Word 文档方法详解

    2023-01-29 08:49:30
  • 基于Spring Boot保护Web应用程序

    2022-11-15 19:14:48
  • Java ShutdownHook原理详解

    2023-11-10 21:30:36
  • java类加载机制、类加载器、自定义类加载器的案例

    2023-02-06 07:35:33
  • C#中Linq查询基本操作使用实例

    2023-11-25 00:25:37
  • java中Executor,ExecutorService,ThreadPoolExecutor详解

    2023-10-31 10:50:56
  • map实现按value升序排序

    2022-10-23 23:13:49
  • Android开发之自定义加载动画详解

    2023-07-27 01:41:05
  • 通过实例学习Either 树和模式匹配

    2023-05-21 02:02:41
  • javaWeb 四大域对象详细介绍

    2021-08-16 14:04:01
  • Java调用CXF WebService接口的两种方式实例

    2023-11-09 02:25:11
  • SpringBoot实现接口数据的加解密功能

    2023-06-30 00:11:01
  • 一篇超详细的Spring Boot整合Mybatis文章

    2022-01-27 10:02:58
  • spring中的注解事务演示和添加步骤详情

    2023-03-03 08:32:48
  • java Spring MVC4环境搭建实例详解(步骤)

    2021-11-17 05:08:08
  • asp之家 软件编程 m.aspxhome.com