Processing math: 100%

07 2020 档案

摘要:CREATE DATABASE `mybatis`; USE `mybatis`; CREATE TABLE `user` ( `id` INT(20) NOT NULL PRIMARY KEY, `name` VARCHAR(20) DEFAULT NULL, `pwd` VARCHAR(30) 阅读全文
posted @ 2020-07-30 00:20 li修远 阅读(221) 评论(0) 推荐(0) 编辑
摘要:1.确保项目结构的正确 确保资源导入成功 如果没有成功,在 pom.xml 中添加如下代码,防止资源导出失败的问题。添加以后,任然未成功,清除maven, 重启idea,再次尝试。 <!--在build中配置resources,来防止我们资源导出失败的问题--> <build> <resources 阅读全文
posted @ 2020-07-30 00:17 li修远 阅读(460) 评论(0) 推荐(0) 编辑
摘要:java项目中可以找到db.properties文件,但使用Tomcat的web项目中却无法找到文件。 可以尝试以下解决方案。 确保web项目中目录WEB-INF/classes下生成了db.properties 文件。 pom.xml 文件中添加如下代码,确保资源导入成功 <!-- 在build中 阅读全文
posted @ 2020-07-28 12:00 li修远 阅读(710) 评论(0) 推荐(0) 编辑
摘要:jsp中导入css三种方式 import 方式 <style type="text/css"> @import url(css/style.css); </style> link 方式 <link type="text/css" rel="stylesheet" href="css/style.cs 阅读全文
posted @ 2020-07-27 20:54 li修远 阅读(536) 评论(0) 推荐(0) 编辑
摘要:public class Demo01 { public static void main(String[] args) { //OOP 规约 7. 所有的相同类型的包装类对象之间值的比较,全部使用 equals 方法比较。 Integer a = 12; Integer b = 12; Syste 阅读全文
posted @ 2020-07-19 10:38 li修远 阅读(632) 评论(0) 推荐(0) 编辑
摘要:等价于求最大元素和最小元素小于target的非空子集问题。 排序 双指针维护满足题意的最大窗口[i, j],方案数目:2^ 注意: 分析重复情况。 class Solution { public int numSubseq(int[] nums, int target) { int n = nu 阅读全文
posted @ 2020-07-14 18:48 li修远 阅读(166) 评论(0) 推荐(0) 编辑
摘要:单调队列,维护合法窗口内的当前最大值(队头)及未来可能成为最大值的元素下标。 class Solution { public int findMaxValueOfEquation(int[][] p, int k) { int n = p.length; int res = Integer.MIN_ 阅读全文
posted @ 2020-07-14 18:31 li修远 阅读(107) 评论(0) 推荐(0) 编辑
摘要:将每个数按照mod k的余数不同分成k类, 负数的余数为负数,特殊处理:(arr[i] % k + k) % k。 class Solution { public boolean canArrange(int[] arr, int k) { int[] cnt = new int[k]; for(i 阅读全文
posted @ 2020-07-14 11:37 li修远 阅读(108) 评论(0) 推荐(0) 编辑
摘要:脑筋急转弯 每只蚂蚁都一样,相遇之后,相当于两人互换身份,继续朝原来的方向前进。因此,找出距离朝向端点最远的蚂蚁需要走多久,就是答案。 class Solution { public int getLastMoment(int n, int[] left, int[] right) { int re 阅读全文
posted @ 2020-07-13 13:06 li修远 阅读(154) 评论(0) 推荐(0) 编辑
摘要:双指针算法 LeetCode 3. 无重复字符的最长子串 while()是非法的,在外更新答案 class Solution { public int lengthOfLongestSubstring(String s) { char[] c = s.toCharArray(); int n = c 阅读全文
posted @ 2020-07-12 21:26 li修远 阅读(100) 评论(0) 推荐(0) 编辑
摘要:import java.util.*; public class Main { static int dijkstra(int[][] g, int n, int target, int k, int value){ boolean[] finished = new boolean[n]; int[ 阅读全文
posted @ 2020-07-12 19:52 li修远 阅读(279) 评论(0) 推荐(0) 编辑
摘要:dijkstra最短路算法,使用贪心策略,解决有权图单源最短路问题。 BFS最短路算法 从源点s开始将顶点依次加入到已确定了最短路径的顶点集合S中,由于图是无权图(每条边权值也可以看做1)。 具体来讲,每次将距离源点s距离为k(k=0,1,2,...)的顶点加入已经确定最短路的顶点S中, 下次再将未 阅读全文
posted @ 2020-07-12 18:57 li修远 阅读(277) 评论(0) 推荐(0) 编辑
摘要:双指针算法 import java.util.*; public class Solution { /** * * @param str1 string字符串 * @param str2 string字符串 * @return string字符串 */ public String getMinStr 阅读全文
posted @ 2020-07-12 16:49 li修远 阅读(192) 评论(0) 推荐(0) 编辑
摘要:美团笔试题-最大矩形 暴力直接解决, 输入处理较为麻烦。 LeetCode 85 一样。 import java.util.*; public class Main { static int solve(int[][] arr, int n, int m) { int area = 0; for(i 阅读全文
posted @ 2020-07-12 15:34 li修远 阅读(192) 评论(0) 推荐(0) 编辑
摘要:import java.util.*; public class Main { static Map<Long, Long> map; static long solve(long n){ if(map.containsKey(n)) return map.get(n); long t = solv 阅读全文
posted @ 2020-07-11 12:49 li修远 阅读(103) 评论(0) 推荐(0) 编辑
摘要:最长上升子序列 import java.util.*; public class Main { static int[] solution(int[] a, int n) { int[] f = new int[n]; for(int i=0; i < n; i++) { f[i] = 1; for 阅读全文
posted @ 2020-07-10 20:54 li修远 阅读(116) 评论(0) 推荐(0) 编辑
摘要:import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNext()){ char[] a = s 阅读全文
posted @ 2020-07-10 18:40 li修远 阅读(145) 评论(0) 推荐(0) 编辑
摘要:在原有重量基础上增加一种重量的砝码,依次使用0,..., m【i】个,得到新的重量,将这些重量添加到集合中,继续重复。 import java.util.*; public class Main { static int solution(int n, int[] m, int[] x){ Set< 阅读全文
posted @ 2020-07-09 18:24 li修远 阅读(165) 评论(0) 推荐(0) 编辑
摘要:深度优先遍历搜索。 从(0,0)开始整个矩阵矩阵,只能向上向下,向左向右走,且前方没有障碍物并且没有走过。遍历过程需要记录下来当前点是从哪个点(如果为点(i,j)存储对于id: i*m+j)走过来的。当遍历到(n,m)时,可以得到一条最短路径。然后从(n,m)倒序恢复整条路径。 import jav 阅读全文
posted @ 2020-07-09 12:31 li修远 阅读(127) 评论(0) 推荐(0) 编辑
摘要:dfs找到解,return true, 不需要继续找了,不然回溯将恢复整个棋盘。 或者, 记录下该解,继续找下一个解(如果存在多解, 但一般不需要)。 import java.util.*; public class Main { static int[][] grid; static boolea 阅读全文
posted @ 2020-07-09 11:20 li修远 阅读(107) 评论(0) 推荐(0) 编辑
摘要:Java 大根堆,维护k个最小的元素,时间复杂度O(NlogK)。 import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); 阅读全文
posted @ 2020-07-07 22:57 li修远 阅读(107) 评论(0) 推荐(0) 编辑
摘要:import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNext()){ int m = sc.n 阅读全文
posted @ 2020-07-07 22:20 li修远 阅读(110) 评论(0) 推荐(0) 编辑
摘要:题目描述存在错误, 应该是固定子序列长度。 双指针算法,时间复杂度O(N)。 import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(Syste 阅读全文
posted @ 2020-07-07 21:43 li修远 阅读(115) 评论(0) 推荐(0) 编辑
摘要:生成4个数的全排列, 和3个操作符的全排列,判断是否运算结果为24。 import java.util.*; public class Main { static boolean res; static boolean is24(int[] a, int n, char[] op) { int re 阅读全文
posted @ 2020-07-07 17:54 li修远 阅读(210) 评论(0) 推荐(0) 编辑
摘要:f[i][j] 表示 a[0,...,i-1] 和 b[0,...,j-1] 能否匹配。 import java.util.*; public class Main { static boolean isMatch(char[] a, char[] b) { int n = a.length, m 阅读全文
posted @ 2020-07-07 13:44 li修远 阅读(175) 评论(0) 推荐(0) 编辑
摘要:思路:构造一颗二叉树,递归计算左右子树的计算量, 再加上左子树矩阵*右子树矩阵的计算量。 坑:测试数据存在右括号多于左括号数量的情况,需要特殊处理一下。 import java.util.*; public class Main { public class Node { Node left, ri 阅读全文
posted @ 2020-07-07 12:26 li修远 阅读(369) 评论(0) 推荐(0) 编辑
摘要:判断闰年:4年闰, 100年不闰, 400 年再闰。 import java.util.*; public class Main { static boolean isLeapYear(int year) { if(year % 400 == 0 || (year % 4 == 0 && year 阅读全文
posted @ 2020-07-06 22:51 li修远 阅读(426) 评论(0) 推荐(0) 编辑
摘要:公共子序列 f[i][j]表示a[0,...,i-1] 和 b[0,...,j-1] 最长公共子序列的长度。 import java.util.*; public class Main { static int solution(char[] a, char[] b) { int n = a.len 阅读全文
posted @ 2020-07-06 20:15 li修远 阅读(110) 评论(0) 推荐(0) 编辑
摘要:import java.util.*; public class Main { static List<String> res; static Stack<Integer> stk; static void dfs(int[] a, int n, int u, String path, int ti 阅读全文
posted @ 2020-07-06 19:15 li修远 阅读(112) 评论(0) 推荐(0) 编辑
摘要:import java.util.*; import java.math.BigInteger; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); whi 阅读全文
posted @ 2020-07-06 11:31 li修远 阅读(140) 评论(0) 推荐(0) 编辑
摘要:import java.util.*; public class Main { static int getDistance(char[] a, int m, char[] b, int n) { int[][] f = new int[m+1][n+1]; for(int i=0; i <= m; 阅读全文
posted @ 2020-07-06 11:21 li修远 阅读(164) 评论(0) 推荐(0) 编辑
摘要:分数为:a / b, a < b。 从1/2 , 1/3 ..., 1/ i , ... 1/ k 依次寻找。 如果1/i > a / b, 继续向后找。 如果1/i ⇐ a / b, 添加 1 / i , a / b - 1/ i 得到新的a,b, 如果此时a == 0, 结束。 import j 阅读全文
posted @ 2020-07-03 23:36 li修远 阅读(199) 评论(0) 推荐(0) 编辑
摘要:import java.util.*; public class Main { static boolean dfs(List<Integer> list, int sum3, int sum5, int u) { if(u == list.size()) { return sum3 == sum5 阅读全文
posted @ 2020-07-02 19:26 li修远 阅读(109) 评论(0) 推荐(0) 编辑
摘要:暴力寻找每个被感染的点是否是起点v。对于每个起点v,广度优先遍历扩散一遍,扩散后结果和S集相同,则v是可能结果。 import java.util.*; public class Main { static boolean bfs(Set<Integer>[] g, int n, int x, bo 阅读全文
posted @ 2020-07-01 22:42 li修远 阅读(148) 评论(0) 推荐(0) 编辑
摘要:邻接矩阵存储图,n<= 100, 使用多源最短路算法Floyd算法(O(n3)),求出重要城市之间最短路径。 遍历所有可能的配对,找出最小路径代价。具体的,求出所有重要城市的全排列,让相邻两城市配对,累加路径代价,再更新最小代价。 import java.util.*; public cl 阅读全文
posted @ 2020-07-01 21:51 li修远 阅读(144) 评论(0) 推荐(0) 编辑
摘要:import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()) { char[] s1 阅读全文
posted @ 2020-07-01 19:33 li修远 阅读(157) 评论(0) 推荐(0) 编辑
摘要:原来有n个公交车站,有m条公交线路。对于其中一条线路a->b->c,使得a,b,c三个公交车站距离变成了1(1块钱可以到达)。因此,我们建立无向图(边全值为1)。但是公交线路长度很长(2<=t ⇐100000),这样对一个公交线路来说,建边复杂度为105×105。为了降低复杂度,每 阅读全文
posted @ 2020-07-01 12:30 li修远 阅读(396) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示