自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Optional 的用法

如果ofNullable不为空,orElse 会有value输出, orElseGet则不会有值。这是因为orElseGet是懒计算,notNullName有值,method不会被调用,而orElse则不是。orElse 和 orElseGet 源码,orElse入参是一个泛型T,orElseGet入参是一个Supplier。创建的Option实例可以为空。get获取Optional的值,如果为空的话,会报。用of 创建的Option实例必须为非空,用。创建一个为空的optional实例。

2024-03-24 22:27:01 181

原创 Java里的泛型<T> T 的运用

因为我总是写一些CRUD的代码,泛型的知识都忘得差不多了,今天特地来写一下。如果方法返回的是空的话,需要在public 和 void 之间加上 <T>在类的名称后面加上 <T>,构建类的时候在<>里写明类型。泛型可以认为是 把类型参数化,方便代码重用。我有两个数组,写一个方法得到最后的一个元素。

2024-03-09 19:53:38 261 1

原创 Spring注释 @Service @Qualifier @Repository

spring 注释

2023-03-22 22:42:57 171

原创 Docker部署运行Nginx

docker 部署 nginx

2023-01-26 13:00:48 170

原创 Linux CentOS 安装配置 MariaDB

centOS 安装 数据库

2022-09-04 21:35:19 1309

原创 Centos7 NAT模式静态IP配置

配置centos7 网卡, xshell 登录

2022-09-04 18:48:26 201

原创 Leetcode My calender

My calendar IImplement a MyCalendar class to store your events. A new event can be added if adding the event will not cause a double booking.Your class will have the method, book(int start,

2017-11-20 05:06:33 216

原创 Leetcode 230. Kth Smallest Element in a BST

Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST's total elements.给一个BST, 找到第 K 小的数方法

2017-10-01 08:53:12 162

原创 Leetcode Combination

Combination Sum 1Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated

2017-08-29 12:27:40 502

原创 recursive and iterative ways to reverse a LinkedList

public ListNode reverseList(ListNode head) { return helper(head, null); } private ListNode helper(ListNode head, ListNode newHead) { if (head == null) return newHead; L

2017-08-29 04:58:02 283

原创 Read N Characters Given Read4

The API: int read4(char *buf) reads 4 characters at a time from a file.The return value is the actual number of characters read. For example, it returns 3 if there is only 3 characters left in the

2017-08-16 19:55:34 220

原创 Leetcode 174. Dungeon Game

The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially p

2017-08-16 16:57:47 136

原创 Leetcode 269. Alien Dictionary

There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list of non-empty words from the dictionary, where words are sorted le

2017-08-16 00:59:20 396

原创 Leetcode 130. Surrounded Regions

Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,

2017-08-15 16:20:29 160

原创 Leetcode 658. Find K Closest Elements

Given a sorted array, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If there is a tie, the smaller elements are always p

2017-08-14 22:45:16 872

原创 Leetcode 126. Word Ladder II

Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such that:Only one letter can be changed at a timeEac

2017-08-05 18:44:34 213

原创 word break/pattern/ladder

139. Word BreakGiven a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dic

2017-08-05 18:36:24 361

原创 Leetcode Best Time to Buy and Sell Stock 全集

Best Time to Buy and Sell Stock ISay you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy

2017-08-03 01:53:51 420 1

原创 Leetcode 395. Longest Substring with At Least K Repeating Characters

Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than k times.Example 1:Input:s = "aaabb", k =

2017-08-02 22:35:20 158

原创 Leetcode 410. Split Array Largest Sum

Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m sub

2017-08-01 15:14:37 165

原创 Leetcode 149. 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.思路是:用两个循环去查看所有情况same 表示两个点完全重合sameX 表示两个点有相同的x坐标public int maxPoints(Point[] poin

2017-08-01 01:23:26 168

原创 Leetcode 464. Can I Win

In the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach or exceed 100 wins.What if we change the game s

2017-07-30 22:28:23 209

原创 Leetcode 368. Largest Divisible Subset

Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0.If there are multiple solution

2017-07-30 15:57:59 163

原创 Leetcode 315. Count of Smaller Numbers After Self

You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].Example

2017-07-26 18:06:43 321

原创 Leetcode 310. Minimum Height Trees

For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called mini

2017-07-26 16:05:12 155

原创 Leetcode 300. Longest Increasing Subsequence

Given an unsorted array of integers, find the length of longest increasing subsequence.For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The longest increasing subsequence is [2, 3, 7, 101], ther

2017-07-25 22:00:25 185

原创 Leetcode 373. Find K Pairs with Smallest Sums

You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k.Define a pair (u,v) which consists of one element from the first array and one element from the second a

2017-07-21 14:54:00 160

原创 Leetcode 621. Task Scheduler

Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks.Tasks could be done without original order. Each task could b

2017-07-21 14:37:34 324

原创 Leetcode Basic Calculator I && II

Implement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and em

2017-07-20 01:04:04 155

原创 Leetcode 282. Expression Add Operators

Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or *between the digits so they evaluate to the target value.Exam

2017-07-19 20:04:31 158

原创 Leetcode 261. Graph Valid Tree

Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree.For example:Given n = 5 an

2017-07-19 00:05:53 764

原创 Leetcode 115. Distinct Subsequences

Given a string S and a string T, count the number of distinct subsequences of S which equals T.A subsequence of a string is a new string which is formed from the original string by deleting some (

2017-07-18 22:14:15 182

原创 Leetcode 305. Number of Islands II

A 2d grid map of m rows and n columns is initially filled with water. We may perform an addLand operation which turns the water at position (row, col) into a land. Given a list of positions to opera

2017-07-18 18:23:25 357

原创 Leetcode 547. Friend Circles

There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, the

2017-07-18 17:22:36 327

原创 Leetcode 133. Clone Graph

Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each

2017-07-18 15:05:26 165

原创 Course Schedule I && II 总结

There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as

2017-07-17 21:36:30 217

原创 Leetcode 72. Edit Distance

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:

2017-07-17 16:28:30 132

原创 Leetcode 159. Longest Substring with At Most Two Distinct Characters

Given a string, find the length of the longest substring T that contains at most 2 distinct characters.For example, Given s = “eceba”,T is "ece" which its length is 3. public in

2017-07-17 01:30:20 588

原创 Leetcode 76. Minimum Window Substring

Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BAN

2017-07-16 23:25:19 342

原创 Leetcode 416. Partition Equal Subset Sum

Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.Note:Each of the array

2017-07-15 21:20:37 116

空空如也

空空如也

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

TA关注的人

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