- 博客(17)
- 收藏
- 关注
原创 Springboot+MongoDB
概述:可以使用MongoTemplate或继承MongoRepository接口1. MongoRepository接口若继承MongoRepository接口可以实现简单的增删改查操作,不用写相应的dao层代码// MongoRepository<T, ID> T为实体类,ID为主键IDpublic interface StdRepository extends MongoRepository<StdDto,Long> {}2. MongoTempla
2022-05-16 16:04:01
577
原创 JSONObject
JSONObject只是一种数据结构,是key-value格式1.导入依赖<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.75</version></dependency>2.创建2.1 直接创建JSONObject obj = n
2022-05-16 15:55:21
336
原创 Java反射
能够分析类能力的程序成为反射,反射机制可以用来:在运行时分析类的能力 在运行时检查对象 实现泛型数组操作代码 利用Method对象1. Class类在程序运行期间,Java运行时系统始终为所有对象维护一个运行时类型标识。这个信息会跟踪每个对象所属的类。虚拟机利用运行时类型信息选择要执行的正确的方法。可以使用一个特殊的Java类访问这些信息。保存这些信息的类型为Class,Object类中的getClass()方法将会返回一个Class类型的实例。获取Class对象的三种方...
2022-05-16 13:49:57
469
原创 MongoDB查询
Person表结构如下图所示 1. 查询全部sqlselect * from person;mongodbdb.person.find()2. 只显示name和age字段sqlselect name,age from person;mongodbdb.person.find({},{name:1,age:1,_id:0})_id默认显示,若不想显示_id则需标注成0,其他字段默认不显示3. 查询姓名是"To......
2022-05-07 14:28:17
4589
原创 LeetCode(5)Longest Palindromic Substring最长回文子串
输出S中的最长回文串eg.Input: s = "babad"Output: "bab"Approach 1纯暴力匹配,提交超时Approcah 2 Manacher算法将暴力匹配的算法复杂度提升到O(n),先对S进行处理,每个字符前后插入"#"(或其他S内不可能出现的字符),经过处理的S'长度一定为奇数,分别以每一个字符为中心计算他的回文半径len,原字符串中它的回文长度为len-1,所以问题变为求每一个字符的len[i]。p:最右回文边界center:当前p的中心.
2021-07-16 11:10:11
85
原创 Dynamic Programming动态规划
1、介绍 动态规划是通过组合子问题的解而解决整个问题,动态规划适用于子问题不是独立的情况,也就是各子问题包含公共的子子问题。动态规划算法对每个子子问题只求解一次,将其结果保存在一张表中,从而避免每次遇到各个子问题时重新计算。 动态规划通常应用于最优化问题,此类问题可能有很多种可行解。每个解有一个值,而我们希望找出一个具有最优(最大或最小)值的解。称这样的解为该问题的“一个”最优解(而不是“确定”的“最优解”),因为可能存在多个取最优值的解。 动态规划算法...
2021-06-29 14:10:25
60
原创 LeetCode(66)Plus One
题目:Given anon-emptyarray of decimal digitsrepresenting a non-negative integer, incrementone to the integer.The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single digit....
2021-06-10 14:37:42
72
原创 LeetCode(53)Maximum Subarray
题目:Given an integer arraynums, find the contiguous subarray (containing at least one number) which has the largest sum and returnits sum.思路:返回由相邻数组相加得到的最大的和class Solution { public int maxSubArray(int[] nums) { int sum = nums[0]; in..
2021-06-07 17:37:33
69
原创 LeetCode(21) Merge Two Sorted Lists
题目:Merge two sorted linked lists and return it as asortedlist. The list should be made by splicing together the nodes of the first two lists.将两个ListNode按照顺序拼接成一个,一开始想通过l1.val和l2.val比较大小,再借助ListNode temp将其插入至其中一个ListNode中,但在一开始调试过程中发现,若temp=q;(q=l2...
2021-06-02 09:46:39
60
原创 LeetCode(14)Longest Common Prefix
题目:Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string"".思路:要求输出strs中最长重复的字符串,使用String类中的compareTo()方法比较字符串,使用substring(int beginIndex,int endIndex)截取字符串。该方法判断较.
2021-05-25 13:37:00
64
原创 LeetCode 2.Add Two Numbers
题目:You are given twonon-emptylinked lists representing two non-negative integers. The digits are stored inreverse order, and each of their nodes contains a single digit. Add the two numbers and return the sumas a linked list.You may assume the two ...
2021-05-18 14:29:22
75
原创 LeetCode刷题(一)Two Sum
题目:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the ...
2019-05-14 09:56:30
118
原创 Springboot(一)
第一个Springboot创建maven配置略<pom.xml>代码如下<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance...
2019-04-22 18:16:05
81
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人