自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 yfd

(1)二叉树,节点的值是0或1,删除值为0的叶子节点(2)BST知道吗?给一个序列,构建一颗BST作者:stitchohana链接:https://www.nowcoder.com/discuss/236679?type=all&order=time&pos=&page=2来源:牛客网1.栈排序2.链表实现队列3.最长连续递增序列4.最长不连续序列5.二维...

2019-09-02 17:31:09 797

原创 Reactor一些用法

1.Flux(byte[])转byte[]:storageFacade.read(key).collectList().map(list -> Iterables.toArray(list, byte[].class)).map(Bytes::concat)

2019-08-23 11:01:19 534

原创 LeetCode57 插入区间

设置新插入的区间为pre,当pre和cur没交集且pre在前面(pre.end<cur.start),则添加pre,没交集且pre在后面(cur.end<pre.start),则添加cur。若有交集,则更新pre。public List<Interval> insert(List<Interval> intervals, Interval newInterva...

2019-04-07 16:02:31 419

原创 LeetCode56 合并区间

前后两区间连的上(pre.end>=cur.start)则只用更新pre.end,连不上就添加区间public List<Interval> merge(List<Interval> intervals) { if(intervals == null || intervals.size() == 0) return new ArrayList<...

2019-04-07 15:54:56 210

原创 Lintcode7 二叉树的序列化和反序列化

public class Solution { /** * This method will be invoked first, you should design your own algorithm * to serialize a binary tree which denote by a root node to a string which * c...

2019-04-07 13:48:50 235

原创 智力题

跑马 https://blog.csdn.net/wtwzd002/article/details/70154526两个鸡蛋100层楼 https://www.cnblogs.com/yangai/p/5391533.html

2019-03-27 11:47:35 314

原创 实现生产者消费者wait/notify

import java.util.ArrayList;import java.util.List;public class ProAndCon { static class Consumer implements Runnable{ private List<Integer> queue; public Consumer(List&lt...

2019-03-26 19:58:36 831

原创 多线程之猴子取苹果

public class Apple { public static volatile int clientTotal = 9;//共有9个苹果 //同时并发执行的线程数:两个猴子各一个线程 public static void main(String[] args){ Thread monkeyOne = new Thread(new Runnabl...

2019-03-21 13:24:24 858

原创 三个线程打印数字

三个线程1,2,3,轮流打印123,456,789,直到100public class Solution { static Object object = new Object(); static int count = 1 ; static int c = 0; static class MyPrintThread ex...

2019-03-21 12:55:23 635

原创 一些面经帖

百度:https://www.nowcoder.com/discuss/111454?type=2&order=0&pos=193&page=1阿里:https://www.nowcoder.com/discuss/164929?type=2&order=0&pos=122&page=1https://www.nowcoder.com/discu...

2019-03-20 18:09:38 199

原创 LeetCode股票题

121.https://leetcode.com/problems/best-time-to-buy-and-sell-stock/只能买卖一次,先买后卖先做差值,然后相当于求最大连续子数组public int maxProfit(int[] prices) { int sum = 0; int max = 0; for(int i = 1; ...

2019-03-14 12:15:39 253

原创 线程安全策略

不可变对象需要满足的条件:(参考String类)对象创建以后其状态就不能修改对象所有域都是final类型对象是正确创建的(在对象创建期间,this引用没有逸出)final关键字:修饰类:不能被继承修饰方法:锁定方法不能被继承类修改(一个类的private方式会隐式地被指定为final方法)修饰变量:基本数据类型变量,引用类型变量(对于引用类型变量只是不能指向新的对象,但对象里地...

2019-01-17 12:17:21 134

原创 LintCode379 将数组重新排序以构造最小值

给定一个整数数组,请将其重新排序,以构造最小值。样例给定 [3, 32, 321],通过将数组重新排序,可构造 6 个可能性数字:3+32+321=3323213+321+32=33213232+3+321=32332132+321+3=323213321+3+32=321332321+32+3=321323其中,最小值为 321323,所以,将数组重新排序后,该数组变为 [32...

2019-01-15 17:20:03 186

原创 LintCode3 统计数字

计算数字k在0到n中的出现的次数,k可能是0~9的一个值样例例如n=12,k=1,在 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],我们发现1出现了5次 (1, 10, 11, 12)public class Solution { /** * @param k: An integer * @param n: An integ...

2019-01-15 17:17:54 217

原创 LintCode1 不使用加法运算符计算a+b

public int aplusb(int a, int b) { // write your code here while(b != 0){ int _a = a ^ b; int _b = (a &amp; b) &lt;&lt; 1; a = _a; b = _b...

2019-01-15 17:07:08 218

原创 LintCode365 二进制中有多少个1

public class Solution { /** * @param num: an integer * @return: an integer, the number of ones in num */ public int countOnes(int num) { int count = 0; while (nu...

2019-01-15 16:49:35 196

原创 LeetCode8 String to Integer (atoi)

Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this...

2019-01-15 16:11:00 195 1

原创 LeetCode97 交错字符串

Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.Example 1:Input: s1 = “aabcc”, s2 = “dbbca”, s3 = “aadbbcbcac”Output: trueExample 2:Input: s1 = “aabcc”, s2 = “dbbca”,...

2019-01-11 11:00:35 274

原创 LeetCode877 石头游戏

Alex and Lee play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of stones piles[i].The objective of the game is to end...

2019-01-11 10:36:08 331

原创 LeetCode10 正则表达式匹配

Given an input string (s) and a pattern §, implement regular expression matching with support for ‘.’ and ‘*’.‘.’ Matches any single character.‘*’ Matches zero or more of the preceding element.The ...

2019-01-10 23:51:34 210

原创 LeetCode329 矩阵中最长的增长路径

Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside of...

2019-01-09 23:50:02 370

原创 LeetCode354 最大可除子集

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 solutions, retu...

2019-01-09 23:49:12 281

原创 LeetCode354 信封

You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if and only if both the width and height of one envelope is greater than th...

2019-01-09 23:48:09 452

原创 LeetCode403 跳蛙

A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.Given a list of st...

2019-01-09 12:15:06 352

原创 LeetCode72 Edit Distance

Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2.You have the following 3 operations permitted on a word:Insert a characterDelete a characte...

2019-01-09 11:50:00 94

原创 LeetCode322 硬币组合

You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money ...

2019-01-09 10:40:33 455

原创 LeetCode5 最长回文子串

Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example 1:Input: “babad”Output: “bab”Note: “aba” is also a valid answer.Example ...

2019-01-08 12:06:36 178 1

原创 LeetCode115 不同的子序列

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 (can...

2019-01-08 11:34:59 269

原创 LeetCode300 最长递增子序列

Given an unsorted array of integers, find the length of longest increasing subsequence.Example:Input: [10,9,2,5,3,7,101,18]Output: 4Explanation: The longest increasing subsequence is [2,3,7,101], ...

2019-01-08 11:17:33 120

原创 LeetCode221 最大正方形

Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area.Example:Input:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0Output: 4class Solution { ...

2019-01-08 10:20:08 345

原创 LeetCode279 完美平方数

Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n.Example 1:Input: n = 12Output: 3Explanation: 12 = 4 + 4 + 4.Example 2:Inp...

2019-01-07 11:10:26 174

原创 LeetCode213 入室强盗2

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 house is ...

2019-01-07 10:58:42 156

原创 LeetCode198 入室强盗

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house...

2019-01-07 10:48:27 466

原创 LeetCode120 三角形

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,7],[4,1,8,3]...

2019-01-07 09:51:39 187

原创 LeetCode64 最小路径和

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 right at an...

2019-01-06 11:28:30 116

原创 LeetCode63 独特的路径2

Example 1:Input:[[0,0,0],[0,1,0],[0,0,0]]Output: 2Explanation:There is one obstacle in the middle of the 3x3 grid above.There are two ways to reach the bottom-right corner:Right -&amp;gt; Righ...

2019-01-06 11:13:49 173

原创 LeetCode62 独特的路径

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 reach the bot...

2019-01-06 10:59:40 162

原创 LeetCode70 爬楼梯

递归:(超时)class Solution { public int climbStairs(int n) { if(n == 1) return 1; if(n == 2) return 2; return climbStairs(n-1) + climbStairs(n-2); }}迭代:class Solution {...

2019-01-06 10:44:48 103

原创 LeetCode 子集,组合,排列,回文分区

This structure might apply to many other backtracking questions, but here I am just going to demonstrate Subsets, Permutations, and Combination Sum.Subsets : https://leetcode.com/problems/subsets/pu...

2019-01-04 17:10:43 103

原创 LeetCode494 目标总和

You are given a list of non-negative integers, a1, a2, …, an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.Find out how many...

2019-01-03 11:00:59 128

空空如也

空空如也

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

TA关注的人

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