- 博客(126)
- 收藏
- 关注
![](https://csdnimg.cn/release/blogv2/dist/pc/img/listFixedTop.png)
原创 Netty+Android搭建一个简易聊天室(实现群聊和私聊)
零,前言JRBM项目中无论是好友私聊,公开聊天室,还是比赛平台都需要用到长连接,之前没有接触过网络通信等知识,更别说框架了,因此直接上手netty确实有些困难,在前期主要是在b站上看(https://www.bilibili.com/video/av26415011)这个视频,但是一些名词根本没有接触过,看着代码也只能照着敲,根本不知道网络通信是什么原理,什么是http协议,什么是socket...
2018-09-28 14:09:55
6186
7
原创 House Robber
Leetcode整理之——House Robber系列House Robber系列一共有三道题,分别是:No.198 House RobberNo.213 House Robber IINo.337 House Robber III这个系列是动态规划的代表作,难度层层递进,从简单的动态规划到与二叉树结合,非常具有特色,接下来我就对这三题的思路和解法进行讲解No.198 House Ro...
2020-02-10 23:40:55
245
原创 阿里云docker安装Rocketmq
1.搜索镜像docker search rocketmq2.启动nameserver(会提示自动下载镜像)docker run -d -p 9876:9876 --name rmqserver foxiswho/rocketmq:server-4.5.13.启动brokerdocker run -d -p 10911:10911 -p 10909:10909\ --...
2020-02-10 14:06:29
901
原创 HashMap、ConcurrentHashMap单线程、多线程遍历时修改的异同
一,情景引入JRBM中有一个对球队Websocket在线情况的检测需求:现有ConcurrentHashMap<teamId,JrbmSession> map,jrbmSession包括了session和lastAliveTime,前端每隔3s通过ws连接向服务端发送一次心跳,服务端接收到心跳之后,更新对应JrbmSession中的lastAliveTime。现在有三个线程...
2020-02-06 19:55:51
3505
1
原创 JRBM——6.27问题
问题1:在自由市场刷新时发现可能出现第一页球员填不满表格的情况,如下图:这是因为我设置的自由球员过期事件处理,即从freemarketplayerlist中删除fpid的动作需要处理时间,而在这期间,有可能再对list进行查询,这时候会查到前10个fpid中的9个fpid已经过期,由于我在代码中进行了二次确认,如果发现fpid为null,那么就主动删除,导致原本查询10个球员,最后只返回了...
2019-06-27 21:04:41
203
原创 SpringBoot——Interceptor如何不拦截静态资源
今天碰到一个神坑!!如何让拦截器不拦截静态资源,网上查阅了各种资料,最后得出的结论是:(1)使用"/static/**"是无效的egistry.addInterceptor(sessionInterceptor) .addPathPatterns("/**") .excludePathPatterns("/","/stati...
2019-06-22 14:01:56
13103
10
原创 No.513 Find Bottom Left Tree Value
Problem:Given a binary tree, find the leftmost value in the last row of the tree.Explanation:找二叉树的左下结点My Thinking:层序遍历,从右向左遍历,最后剩余的就是最左结点My Solution:class Solution { public int find...
2019-05-29 19:42:51
127
原创 Tree——No.222 Count Complete Tree Nodes
Problem:Given a complete binary tree, count the number of nodes.Explanation:计算完全二叉树的结点数量。若设二叉树的深度为h,除第 h 层外,其它各层 (1~h-1) 的结点数都达到最大个数,第 h 层所有的结点都连续集中在最左边,这就是完全二叉树。My Thinking:直接递归计算树的结点数(虽然...
2019-05-29 19:41:57
101
原创 Tree——No.199 Binary Tree Right Side View
Problem:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.Explanation:得到树的右视图。My Thinking:层序遍历,将每层...
2019-05-28 16:16:03
120
原创 Tree——No.222 Count Complete Tree Nodes
Problem:Given a complete binary tree, count the number of nodes.Explanation:计算完全二叉树的结点数量。若设二叉树的深度为h,除第 h 层外,其它各层 (1~h-1) 的结点数都达到最大个数,第 h 层所有的结点都连续集中在最左边,这就是完全二叉树。My Thinking:直接递归计算树的结点数(虽然...
2019-05-28 16:14:46
128
原创 String——No.20 Valid Parentheses
Problem:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same...
2019-05-27 18:27:46
138
原创 Tree——No.173 Binary Search Tree Iterator
Problem:Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Explan...
2019-05-27 18:26:50
122
原创 String——No.344 Reverse String
Problem:Write a function that reverses a string. The input string is given as an array of characters char[].Do not allocate extra space for another array, you must do this by modifying the input a...
2019-05-21 21:53:59
163
原创 Tree——No.98 Validate Binary Search Tree
Problem:Given a binary tree, determine if it is a valid binary search tree (BST).Explanation:判断一棵树是否为BSTMy Thinking:左结点范围:(上个结点的下限,上个结点的值)右结点范围:(上个结点的值,上个结点的上限)My Solution:class Solut...
2019-05-21 21:53:16
115
原创 Tree——No.117 Populating Next Right Pointers in Each Node II
Problem:You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:struct Node {int val;Nod...
2019-05-20 21:22:52
147
原创 Dynamic Programming——No.120 Triangle
Problem:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.Explanation:给一个三角形数组,每次只能往下一行的相邻数字走,求走到底的最短路径长度。My Thinking:...
2019-05-20 21:21:34
194
原创 Dynamic Programming——No.213 House Robber II
Problem:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first...
2019-05-16 18:52:54
153
原创 Dynamic Programming——No.64 Minimum Path Sum
Problem:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or ...
2019-05-16 18:23:36
123
原创 Tree——No.116 Populating Next Right Pointers in Each Node
Problem:You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:struct Node {int val;Nod...
2019-05-16 18:19:34
115
原创 Tree——No.337 House Robber III
Problem:The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. Af...
2019-05-14 18:53:52
205
原创 Tree——No.450 Delete Node in a BST
Problem:Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.Note: Time complexity should be ...
2019-05-14 18:53:07
127
原创 LinkedList——No.19 Remove Nth Node From End of List
Problem:Given a linked list, remove the n-th node from the end of list and return its head.Explanation:将链表中倒数第n个结点移除,返回头结点。My Thinking:使用递归,返回到倒数n+1个结点时,将其指针指向后一个结点的后一个结点即可。My Solution:...
2019-05-12 11:20:50
117
原创 Tree——No.105 Construct Binary Tree from Preorder and Inorder Traversal
Problem:Given preorder and inorder traversal of a tree, construct the binary tree.Explanation:将前序遍历和中序遍历还原成二叉树My Thinking:My Solution:Optimum Thinking:preorder的第一个数一定是根,在inorder中找到它的位置in...
2019-05-12 10:53:15
102
原创 Tree——No.106 Construct Binary Tree from Inorder and Postorder Traversal
Problem:Given inorder and postorder traversal of a tree, construct the binary tree.Explanation:将中序遍历和后序遍历还原成二叉树My Thinking:后序遍历的最后一个节点一定是根结点,在inorder中找到它的位置,分为左右两半构成左右子树,左孩子一定是postorder当前-右子...
2019-05-12 10:52:21
101
原创 Tree——No.95 Unique Binary Search Trees II
Problem:Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n?Explanation:给定n,返回可能的包含1-n的所有不重复的搜索二叉树My Thinking:My Solution:Optimum Thinking:深度优先遍历,...
2019-05-10 18:48:47
91
原创 Tree——No.783 Minimum Distance Between BST Nodes/No.530 Minimum Absolute Difference in BST
Problem:Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the values of any two different nodes in the tree.Explanation:找到二叉搜索树结点的最小差值。My Thinking...
2019-05-08 23:22:23
100
原创 Tree——No.103 Binary Tree Zigzag Level Order Traversal
Problem:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).Explanation:二叉树z字...
2019-05-08 23:20:57
95
原创 Tree/Dynamic Programming——No.96 Unique Binary Search Trees
Problem:Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n?Explanation:给定n,返回可能的包含1-n的搜索二叉树的个数My Thinking:My Solution:Optimum Thinking:G(n)是n个数字的...
2019-05-07 18:12:18
100
原创 Tree——No.144 Binary Tree Preorder Traversal
Problem:Given a binary tree, return the preorder traversal of its nodes' values.Explanation:前序遍历二叉树My Thinking:(1)递归(2)使用栈迭代,先入右孩子,再入左孩子。My Solution:(1)class Solution { List<...
2019-05-07 18:11:22
92
原创 Dynamic Programming——No.63 Unique Paths II
Problem:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to re...
2019-05-02 20:50:50
113
原创 LinkedList——No.160 Intersection of Two Linked Lists
Problem:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:Explanation:找两个链表的交点(地址相同的点)My Thinking:My ...
2019-04-28 16:34:47
115
原创 Tree——No.938. Range Sum of BST
Problem:Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive).The binary search tree is guaranteed to have unique values.Expla...
2019-04-28 16:33:35
97
原创 Tree——No.538. Convert BST to Greater Tree
Problem:Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BS...
2019-04-28 16:32:43
98
原创 Tree——No.108 Convert Sorted Array to Binary Search Tree
Problem:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the de...
2019-04-28 16:31:31
103
原创 Dynamic Programming——No.813 Largest Sum of Averages
Problem:We partition a row of numbers A into at most K adjacent (non-empty) groups, then our score is the sum of the average of each group. What is the largest score we can achieve?Note that our p...
2019-04-25 18:02:23
93
原创 Tree——No.993 Cousins in Binary Tree
Problem:In a binary tree, the root node is at depth 0, and children of each depth k node are at depth k+1.Two nodes of a binary tree are cousins if they have the same depth, but have different par...
2019-04-25 17:58:15
163
原创 Tree——No.606 Construct String from Binary Tree
Problem:You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way.The null node needs to be represented by empty parenthesis pair "()"...
2019-04-25 17:56:42
108
原创 Tree——No.653 Two Sum IV - Input is a BST
Problem:Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.Explanation:在搜索二叉树中寻找两数之和。My Thinkin...
2019-04-25 17:55:57
107
原创 Tree——No.226 Invert Binary Tree
Problem:Invert a binary tree.Explanation:将二叉树轴对称翻转。My Thinking:前序遍历,将左右孩子交换。My Solution:class Solution { public TreeNode invertTree(TreeNode root) { if(root==null) ...
2019-04-21 21:11:17
93
原创 Dynamic Programming——No.300 Longest Increasing Subsequence
Problem:Given an unsorted array of integers, find the length of longest increasing subsequence.Explanation:找到最长的连续增长的数列长度,数组中的数字可以跳跃使用。My Thinking:My Solution:Optimum Thinking:dp[i]表示0-i...
2019-04-21 14:34:22
131
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人