自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(14)
  • 收藏
  • 关注

原创 leetcode 572另一棵树的子树 hash树法 1 ms , 99.91%

解题思路设计一个算法让每个树对应一个hash值hash(node) = node.val+hash(node.left)*117 + hash(node.right)*31然后将subRoot的hash求出再对root进行dfs 看有没有hash相同的子树即可代码class Solution { public boolean isSubtree(TreeNode root, TreeNode subRoot) { int hash = dfs(subRoot);//首先

2021-10-17 00:18:56 105

原创 leetcode 110 平衡二叉树

class Solution { public boolean isBalanced(TreeNode root) { if(root == null) return true; else{ boolean isHeightNear = Math.abs( height(root.left) - height(root.right) ) <=1; return isHeightNear && i.

2021-10-16 21:46:47 85 1

原创 leetcode101. 对称二叉树

#leetcode [101. 对称二叉树](https://leetcode-cn.com/problems/symmetric-tree/)##recursion```javaclass Solution { public boolean isSymmetric(TreeNode root) { if(root==null) return true; return dfs(root.left,root.right); } bo...

2021-10-16 16:39:35 82

原创 leetcode 117. 填充每个节点的下一个右侧节点指针 II

解题思路先给下一层建立一个dummyHead 之后把这一层的孩子顺次接上 搞定 去往下一层代码class Solution { public Node connect(Node root) { if(root == null) return root; Node start = root; //遍历所有层 while(start != null){ Node nextLayerDummyHead =...

2021-10-16 15:16:44 56

原创 尝试一文写清楚二叉树遍历(递归,非递归)

目录递归遍历前序递归遍历中序和后序递归遍历非递归遍历递归遍历前序递归遍历首先从简单的开始class Solution { public List<Integer> preorderTraversal(TreeNode root) { List<Integer> ret = new ArrayList<Integer>(); preorderTraversalRecur(root,r...

2021-10-11 00:12:59 124

原创 17-TaBase使用流复制搭建热备节点

1.主机信息 主机名 ip post 角色 master 192.168.1.201 5432 主节点 standby 192.168.1.202 5432 备节点 2.准备2.1.1.主节点和备节点分别安装TaBase。这...

2021-09-16 17:14:53 1485

原创 Clion调试PostgreSQL

1.下载在https://github.com/postgres/postgres/releases页面下载源码(不要直接Git,原因未知)2.调试参考Ubuntu 16.04+CLion配置Postgresql调试环境 - 知乎2.1.新建文件在源码根目录新建CMakeFilelist.txt文件,内容如下 cmake_minimum_required(VERSION 3.6) project(postgres) set(CMAKE_CXX_FLA...

2021-09-16 17:12:53 1719

原创 关于数据库psql登录错误ibreadline.so.6: cannot open shared object file: No such file or directory

解决方案 cd /lib/x86_64-linux-gnu/ sudo ln -slibreadline.so.7.0libreadline.so.6

2021-09-16 17:08:37 1453

原创 数据库执行查询计划详细代码分析

查询调用的函数栈:main()->PostmasterMain()->ServerLoop()->BackendStartup()->BackendRun()->PostgresMain()->exec_simple_query()→其中的postgresmain函数的分析进入下://postgres主循环--所有后端,交互或者其他从这里开始//postgres服务进程voidPostgresMain(int argc, char *argv[],...

2021-09-16 17:07:01 1347

原创 leetcode 417. Pacific Atlantic Water Flow

class Solution { public List<List<Integer>> pacificAtlantic(int[][] heights) { int lengthX=heights.length; int lengthY=heights[0].length; List<List<Integer>> result=new ArrayList<>(); .

2021-06-23 21:23:25 44

原创 leetcode 347 . Top K Frequent Elements

class Solution { public int[] topKFrequent(int[] nums, int k) { Map<Integer,Integer> occurrences=new HashMap<Integer,Integer>(); for(int num:nums){ occurrences.put(num,occurrences.getOrDefault(num, 0)+1); .

2021-06-23 21:22:55 143

原创 leetcode 215. Kth Largest Element in an Array

classSolution{Randomrandom=newRandom();publicintfindKthLargest(int[]nums,intk){returnquickSelect(nums,0,nums.length-1,nums.length-k);}//给出nums里从小到大排在index位置的数intquickSelect(int[]nums,intl,intr,...

2021-06-22 22:10:45 40

原创 leetcode 4

4. Median of Two Sorted ArraysGiven two sorted arraysnums1andnums2of sizemandnrespectively, returnthe medianof the two sorted arrays.The overall run time complexity should beO(log (m+n)).Example 1:Input: nums1 = [1,3], nums2 = [2]Ou...

2021-06-20 18:07:54 45

原创 leetcode 540

classSolution{publicintsingleNonDuplicate(int[]nums){inthi=nums.length;intlo=0;while(lo<hi){intmid=lo+(hi-lo)/2;booleanlatterPartIsEven=(hi-mid)%2==0;...

2021-06-20 14:21:13 39

空空如也

空空如也

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

TA关注的人

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