IDEA2020.1使用LeetCode插件運行并調試本地樣例的方法詳解
環(huán)境: 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:兩數(shù)之和 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"); } } }
總結
到此這篇關于IDEA2020.1使用LeetCode插件運行并調試本地樣例的方法詳解的文章就介紹到這了,更多相關IDEA LeetCode插件運行并調試本地樣例內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
Java redis存Map對象類型數(shù)據的實現(xiàn)
本文主要介紹了Java redis存Map<String,RedisCustom>對象類型數(shù)據,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-05-05Spring Security攔截器引起Java CORS跨域失敗的問題及解決
這篇文章主要介紹了Spring Security攔截器引起Java CORS跨域失敗的問題及解決,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-07-07SpringBoot如何使用slf4j日志及其項目配置、MVC支持
這篇文章主要介紹了SpringBoot如何使用slf4j日志及其項目配置、MVC支持,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-05-05SpringBoot整合Redis哨兵模式的實現(xiàn)示例
Redis哨兵模式是Redis高可用方案的一種實現(xiàn)方式,通過哨兵來自動實現(xiàn)故障轉移,從而保證高可用,本文主要介紹了SpringBoot整合Redis哨兵模式的實現(xiàn)示例,具有一定的參考價值,感興趣的可以了解一下2024-02-02