自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(52)
  • 资源 (1)
  • 收藏
  • 关注

原创 mac m1下navicat执行mongorestore 到mongodb

首先,下载https://www.mongodb.com/try/download/mongocli。解压缩后 有可执行文件使用navicat打开。加载后再重新点击 选择 要恢复的文件即可。

2023-10-31 16:11:20 219

原创 leetcode:26.两数之和 简单

class Solution { public int[] twoSum(int[] nums, int target) { Map<Integer, Integer> map = new HashMap<Integer, Integer>(); for(int i = 0; i < nums.length; i++){ int num = target - nums[i]; if(map.containsKey(num)

2021-12-09 15:26:44 325

原创 leetcode:25.两数相加 中等

class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) { ListNode teamhead=new ListNode(0); ListNode p=l1,q=l2,curr=teamhead; int carry=0; while(p!=null||q!=null){ int x=(p!=null)?p.val:0;

2021-12-09 13:59:37 212

原创 leetcode:24.最大子树和 简单

class Solution { public int maxSubArray(int[] nums) { if(nums == null || nums.length == 0) return 0; int res = nums[0]; int maxI = nums[0]; for(int i = 1;i < nums.length;i ++){ maxI = Math.max(maxI

2021-12-03 14:13:03 433

原创 leetcode:23.移动零 简单

class Solution { public void moveZeroes(int[] nums) { int i = 0;//记录非0元素的个数 for(int j = 0; j < nums.length ; j++){ if(nums[j] != 0){ nums[i++] = nums[j]; } } for(int k = i; k&lt

2021-12-03 14:02:21 46

原创 leetcode:22.比特计位树 简单

找规律:如果 i 为偶数,那么f(i) = f(i/2)如果 i 为奇数,那么f(i) = f(i - 1) + 1class Solution { public int[] countBits(int num) { int[] result = new int[num+1]; result[0] = 0; for(int i = 1; i <= num; i++){ if(i%2==1) result[i] = r

2021-12-03 13:59:26 47

原创 leetcode:21.找到所有数组中消失的数字 简单

还是应用了桶的思想,因为题中条件是不用额外的空间。把i放在nums[i - 1]的位置:首先判断nums[i]是否在它应该在的地方,即nums[i] - 1对应的位置,如果不在就交换,再把交换过来的元素放在它应该在的位置。然后重新遍历一次,发现不符合条件的元素就加入返回数组。如果允许用额外空间的话也可以用标记数组,如果用位图的话需要考虑n的大小。class Solution { public List<Integer> findDisappearedNumbers(int[] num

2021-12-03 13:52:09 422

原创 leetcode:20.汉明距离 简单

class Solution { public int hammingDistance(int x, int y) { int num = 0; int temp = x^y; while (temp != 0) { temp = (temp - 1) & temp; num++; } return num; }}

2021-12-03 10:17:26 54

原创 leetcode:19.二叉树的直径 简单

class Solution { int max=0; public int diameterOfBinaryTree(TreeNode root) { depth(root); return max; } public int depth(TreeNode root){ if(root==null){ return 0; } int leftdepth=depth(ro

2021-12-03 10:09:21 410

原创 leetcode:18.合并二叉树 简单

class Solution { public TreeNode mergeTrees(TreeNode root1, TreeNode root2) { if(root1==null&&root2==null){ return null; } if(root1==null||root2==null){ return root1==null?root

2021-12-02 19:11:22 271

原创 leetcode:17.回文链表 简单

class Solution { public boolean isPalindrome(ListNode head) { if(head==null||head.next==null){//有0个或1个节点 return true; } ListNode right=head.next; ListNode cur=head; //靠cur确定右半区起始点位置(right) while

2021-12-02 14:15:48 46

原创 IDEA中运行maven多模块项目,提示程序包xxxx不存在

Error:(18, 29) java: 程序包com.jhsx.aaa.service不存在Error:(34, 13) java: 找不到符号 符号: 类IGoodService 位置: 类com.jhsx.test.controller.TestController此问题产生原因可能有多种,最常见的可能是jar包未能正常引入。检查下项目是否有报错,maven依赖是否正常导入即可。我的

2021-12-01 16:21:35 2316

原创 leetcode:16.翻转二叉树 简单

class Solution { public TreeNode invertTree(TreeNode root) { if(root==null){ return null; } Queue<TreeNode> queue=new LinkedList<TreeNode>(); queue.add(root); while(!queue.isEmpty()){

2021-12-01 13:44:27 146

原创 leetcode:15.多数元素 简单

class Solution { public int majorityElement(int[] nums) { int count = 1; int maj = nums[0]; for (int i = 1; i < nums.length; i++) { if (maj == nums[i]) count++; else { count--; if (count == 0) { maj = nums[i + 1];

2021-12-01 10:15:07 49

原创 leetcode:14.相交链表 简单

public class Solution { public ListNode getIntersectionNode(ListNode headA, ListNode headB) { if (headA == null || headB == null) return null; ListNode A = headA, B = headB; // 当没有相交时循环 while (A != B) {

2021-12-01 10:03:13 154

原创 leetcode:13.最小栈 简单

class MinStack { private Stack<Integer> data; private Stack<Integer> minStack; /** initialize your data structure here. */ public MinStack() { data = new Stack(); minStack = new Stack(); } public void

2021-12-01 09:49:10 121

原创 leetcode:12.环形链表 简单

public class Solution { public boolean hasCycle(ListNode head) { if(head == null){ return false; } ListNode fast = head.next; ListNode slow = head; while (fast != null && fast.next != null){

2021-11-30 20:06:41 52

原创 leetcode:11.只出现一次的数字 简单

class Solution { public int singleNumber(int[] nums) { for (int i = 1; i <nums.length ; i++) { nums[0] = nums[0]^nums[i]; } return nums[0]; }}

2021-11-30 19:52:18 139

原创 leetcode:10.买卖股票的时机 简单

/** * 这玩意应该是贪心解法 * 设-1买入为无穷大 * 则第一天买入记为第一天的,当有比他小的时候,就买入,相当于原价卖了,再买入。 * 如果比他大,则卖出,切记录此时的利润(因为没有手续费,所以这里是假定卖出,如果有利润更大的存在,则卖出更大的利润 * 例如 2 5 9 则在2买入,5卖出 利润为3 ,因为在9卖出,利润为7,则相当于取消上次的交易) * */class Solution { public int maxProfit(int[] prices) {

2021-11-30 19:13:48 48

原创 leetcode:9.二叉树最大深度 简单

class Solution { int maxDepth=0; int i=1; public int maxDepth(TreeNode root) { if(root==null){ return 0; } int nleft = maxDepth(root.left); int nright = maxDepth(root.right); return nleft >

2021-11-30 17:09:01 135

原创 leetcode:8.对称二叉树 简单

class Solution { public boolean isSymmetric(TreeNode root) { if(root==null){ return true; } return check(root.left,root.right); } public boolean check(TreeNode node1,TreeNode node2){ if(node1==null&a

2021-11-30 17:01:00 134

原创 leetcode:7.二叉树的中序遍历 简单

class Solution { List<Integer> list=new ArrayList<>(); public List<Integer> inorderTraversal(TreeNode root) { if(root==null){ return list; } inorderTraversal(root.left); list.add(root.val)

2021-11-30 16:45:34 50

原创 leetcode:6.爬楼梯 简单

斐波那契数列class Solution { public int climbStairs(int n) { if (n == 0) { return 0; } if (n == 1) { return 1; } int first = 1; int second = 2; int temp = 0; for (int i = 3; i <= n; i++) { temp = first + second; first = sec

2021-11-30 16:26:30 51

原创 leetcode:5.合并两个有序链表 简单

class Solution { public ListNode mergeTwoLists(ListNode list1, ListNode list2) { if(list1==null&&list2==null){ return null; } if(list1==null){ return list2; } if(list2==null){

2021-11-30 15:58:53 49

原创 leetcode:4.有效的括号 简单

class Solution { public boolean isValid(String s) { Stack<Character> stack=new Stack(); for(int i=0;i<s.length();i++){ char t=s.charAt(i); if(t=='('||t=='{'||t=='['){ stack.push(t);

2021-11-30 15:42:10 52

原创 剑指offer :从头到尾打印链表 简单

class Solution { public int[] reversePrint(ListNode head) { Stack<ListNode> stack = new Stack<ListNode>(); ListNode temp = head; while (temp != null) { stack.push(temp); temp = temp.next;

2021-11-30 11:17:05 53

原创 leetcode:3.合并两个有序数组 简单

class Solution { public void merge(int[] nums1, int m, int[] nums2, int n) { int i=m-1,j=n-1,k=m+n-1; while (i>=0&&j>=0){ if(nums1[i]>nums2[j]){ nums1[k--]=nums1[i--]; }else {

2021-11-29 17:04:05 116

原创 leetcode:2.链表反转 简单

class Solution { public ListNode reverseList(ListNode head) { if(head==null||head.next==null){ return head; } ListNode temp=head.next; ListNode newHead=reverseList(head.next); temp.next=head;

2021-11-29 17:01:43 136

原创 leetcode:1.最长无重复子串 中等

class Solution { public int lengthOfLongestSubstring(String s) { Set<Character> set=new HashSet(); int right=-1; int maxlength=0; for(int i=0;i<s.length();i++){ if(i!=0){ set.remo

2021-11-29 16:58:45 42

原创 自定义注解获取post方法中body的值

首先设定实体类@Datapublic class AuthorizeCache { private String scheme; private String authorizeKey; private String userName;}设置注解 定义目标范围为参数@Target(ElementType.PARAMETER)@Retention(RetentionPolicy.RUNTIME)public @interface AuthorizeUser {

2021-10-28 15:35:23 882

原创 kafka pull模式 提交offset失败问题

网上都是消息监听,接口调用时,同一个消费组,无法使用为同一个消费者,所以需要取消订阅。 Properties properties=kafkaConfig.getProperties(); // 将参数设置到消费者参数中 KafkaConsumer<String, String> consumer = new KafkaConsumer(properties); List<String> list=new ArrayList<

2021-10-19 17:02:38 447

原创 线程池使用注意点!!!!

1.线程池堵塞情况:使用spring提供的线程池ThreadPoolTaskExecutor注入并使用,不可同时使用submit有返回值和execute没有返回值。因为execute没有返回值的也会堵塞。2.线程池调用时间过长情况:任务实现不成功 日志不报错,任务定时调用线程池,定位问题定位到线程池调用时间过长 使用线程池监控才找到问题 日志不报错 难以找到问题...

2021-10-12 15:41:17 108

原创 leetcode 整数反转

class Solution { public int reverse(int x) { char[] ars=String.valueOf(x).toCharArray(); String result=""; for(int i=ars.length-1;i>0;i--){ result=result+ars[i]; } return Integer.valueOf(result);

2021-09-07 11:03:46 30

原创 leetcode LRU缓存刷新算法

此算法是使用hashmap 与linkedlist解出 具体见代码。class LRUCache { private int capacity; private HashMap<Integer,Integer> map =new HashMap<>(); private LinkedList<String> list; public LRUCache(int capacity) { this.capacity=ca

2021-09-02 17:25:06 76

原创 2021-06-02

if(list.stream().filter(item->item.getUserId().equals("123456")).findAny().isPresent()){//存在则代码块执行业务逻辑代码}

2021-06-02 14:57:33 29

原创 java获取数据库信息,表字段,类型

@Resource private DataSource dataSource; private static final String SQL = "SELECT * FROM ";// 数据库操作 /** * 关闭数据库连接 * @param conn */ public void closeConnection(Connection conn) { if(conn != null) { ...

2021-05-21 11:10:59 1313

原创 解决同事地址注册到eureka为虚拟机ip问题

帮同事注册服务到eureka,并添加动态路由信息进行访问。爆ip访问异常经排查是ip地址不对 使用的是虚拟机ip vmvare net1首先简单的将虚拟机网络禁用 然后仍然通过网关访问不到报以下异常[网关异常处理]请求路径:/reform-lg/doc.html,异常信息:503 SERVICE_UNAVAILABLE "Unable to find instance for reform-number-lg"2021-04-03 14:10:14,303 ERROR (GatewayExce

2021-04-03 14:45:14 642

原创 路径访问不到

有可能是路径 有可能是配置文件 遇见一次一个是apllication和application-dev访问不成功 但是将application转为bootstrap成功了

2021-04-01 14:15:10 93

原创 maven打包问题

maven父文件打包失败 是因为父文件没有打包 所以单个打包失败将此父类的模块去除后一一打包 即可成功

2021-04-01 10:16:32 68

原创 程序包不存在

1.程序包不存在问题

2021-03-24 10:29:29 113

笔记2232 真的非常不错

笔记2232 真的非常不错

2022-02-10

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除