自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 json schema 反射生成

java 类型生成jsonschema

2022-12-06 11:34:29 371

原创 转换list为map (1个key 对应 多个value)

public static <K, V, O> Map<K, Set<V>> oneToManyMap(List<O> list, Function<O, K> keyFunction, Function<O, V> valueFunction) { if (list == null) { ...

2019-07-22 13:20:44 1789

原创 Python:动态代理机制

最近开始学习python,发现python很方便,提供了丰富的函数支持反射,本人之前主要以java编程为主,在学习python的过程中,学习到了Python的装饰器,结合之前java的代理模式,于是想要编写基于python的对象代理代理模式的理论知识网上有很多相关的材料,总而言之就是对象有一个配套的代理对象,对代理对象进行调用时,代理对象转发调用给实际对象本身下面介绍一些自己写的一些类:Proxy...

2018-06-04 13:56:12 3841

原创 LeetCode sum-root-to-leaf-numbers

题目描述Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1-&gt;2-&gt;3which represents the number123.Find the total sum...

2018-05-20 11:46:47 161

原创 Leetlongest-consecutive-sequence

题目描述Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is[1, 2, 3, 4]. ...

2018-05-20 11:46:40 99

原创 LeetCode word-ladder-ii

题目描述Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:Only one letter can be changed at a timeEach intermediate word must exi...

2018-05-20 11:46:33 184

原创 LeetCode word-ladder

题目描述Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach intermediate word m...

2018-05-20 11:45:56 122

原创 LeetCode valid-palindrome

题目描述Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama"is a palindrome."race a car"is not a palind...

2018-05-20 11:45:49 156

原创 LeetCode binary-tree-maximum-path-sum

题目描述Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3Return6.解题思路:记录一个全局的值为max,然后...

2018-05-20 11:45:42 122

原创 LeetCode best-time-to-buy-and-sell-stock-iii

题目描述Say you have an array for which the i th element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note: You may not ...

2018-05-20 11:45:35 190

原创 best-time-to-buy-and-sell-stock-ii

题目描述Say you have an array for which the i th element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy o...

2018-05-20 11:45:28 249

原创 LeetCode best-time-to-buy-and-sell-stock

题目描述Say you have an array for which the i th element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock)...

2018-05-20 11:45:20 177

原创 LeetCode triangle

题目描述Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,5,...

2018-05-20 11:45:12 91

原创 LeetCode copy-list-with-random-pointer

题目描述A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.解题思路:对于每个节点都copy一个节点,令copy的节点变成原来节...

2018-05-19 08:45:28 148

原创 LeetCode single-number-ii

题目描述Given an array of integers, every element appears three times except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without usin...

2018-05-19 08:45:21 121

原创 LeetCode single-number

题目描述Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extr...

2018-05-19 08:45:06 135

原创 LeetCode candy

题目描述There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least one ca...

2018-05-19 08:44:59 177

原创 LeetCode gas-station

题目描述There are N gas stations along a circular route, where the amount of gas at station i isgas[i].You have a car with an unlimited gas tank and it costscost[i]of gas to travel from station i to its n...

2018-05-19 08:44:53 91

原创 LeetCode clone-graph

题目描述Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use#as a separator for each node, and,...

2018-05-19 08:44:47 130

原创 LeetCode word-break

题目描述Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens ="leetcode",dict =["leet", "cod...

2018-05-19 08:44:40 227

原创 LeetCode word-break-ii

题目描述Given a string s and a dictionary of words dict, add spaces in sto construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, givens ="catsandd...

2018-05-19 08:44:30 175

原创 LeetCode palindrome-partitioning-ii

题目描述Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs.For example, given s ="aab",Return1since t...

2018-05-19 08:43:12 127

原创 LeetCode linked-list-cycle

题目描述Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s ="aab",Return [ ["aa","b"], ...

2018-05-19 08:43:03 56

原创 LeetCode linked-list-cycle

题目描述Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?解决思路:一种方法就是利用HashSet,依次遍历链表,每访问一个节点就判断是否已经存在于HashSet中,如果有,则返回true,没有 返回false第二种方法就是利用fas...

2018-05-18 21:34:42 61

原创 LeetCode linked-list-cycle-ii

题目描述Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?解题思路:建立一个HashSet, 每访问一个节点就判断HashSet中是否已经存在,如果有,则直...

2018-05-18 21:30:02 157

原创 LeetCode reorder-list

题目描述Given a singly linked list L: L 0→L 1→…→L n-1→L n,reorder it to: L 0→L n →L 1→L n-1→L 2→L n-2→…You must do this in-place without altering the nodes' values.For example,Given{1,2,3,4}, reorder it t...

2018-05-18 21:26:39 84

原创 LeetCode binary-tree-preorder-traversal

题目描述Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].Note: Recursive solution is trivial, could...

2018-05-18 17:35:22 88

原创 LeetCode binary-tree-postorder-traversal

题目描述Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].Note: Recursive solution is trivial, coul...

2018-05-18 17:32:58 61

原创 LeetCode insertion-sort-list

题目描述Sort a linked list using insertion sort.解题思路:插入排序的思想,初始输出链表为空,然后遍历输入的链表,记每个访问的节点为cur1 如果输出链表为空,则直接插入cur2 如果输出链表的头节点的值 &gt; cur.val 则将cur作为输出链表的新的头3 如果输出链表的尾节点的值 &lt; cur.val 则直接插入cur4 从尾往前扫输出链表,遇到...

2018-05-18 17:30:23 113

原创 LeetCode sort-list

题目描述Sort a linked list in O(n log n) time using constant space complexity.解决思路看到题目中的 nlogn 以及 sort,很自然的联想到mergesort的思想。只不过mergesort通常是以排序数组元素出现的,现在变成了排序链表。class ListNode { int val; ListNode next; ...

2018-05-18 17:22:04 195

原创 LeetCode max-points-on-a-line

题目描述Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.解决思路:因为任意两个点就能形成一条线两个点的情况有三种:重合一条垂直x轴的线普通直线1.固定两点中的一个点,然后另一个点为任意的点,同时建立一个哈希表保存固定点形成线的斜率以及对应的次数形式为...

2018-05-18 17:17:35 116

原创 LeetCode evaluate-reverse-polish-notation

题目描述Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another expression. Some examples:   ["2", "1", "+", "3", "*...

2018-05-18 17:02:31 67

原创 LeetCode minimum-depth-of-binary-tree

题目描述Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.解决思路判断树的最小深度,第一思路就是递归的方法:情况1: 当前节点为空: ...

2018-05-18 16:56:44 58

空空如也

空空如也

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

TA关注的人

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