自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 整数数组能组成的最大数字

public class Temp { public static String largestNumber(int[] nums) { String[] numStrArray = new String[nums.length]; for (int i = 0; i < nums.length; i++) { numStr...

2020-04-15 17:30:41 1153

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

import java.util.Arrays;import java.util.Iterator;import java.util.LinkedList;import java.util.List;class TreeNode { int val; TreeNode left; TreeNode right; TreeNode(int x) { ...

2020-04-15 16:56:53 205

原创 字母序列和数字转换

public class Temp { //数字转字母序列 -> 10进制转26进制 public static String numToLetters(int num) { if (num <= 0) { return ""; } String result = ""; whi...

2020-04-13 23:16:40 569

原创 八皇后问题

import java.util.ArrayList;import java.util.List;public class Temp { public static int[][] chessboard = new int[8][8]; public static List<String> solutionStrs = new ArrayList<>...

2020-04-13 22:14:09 257

原创 数组中寻找峰值

public class Solution { //只存在一个峰值 public static Integer findMaxNum(int[] nums) { if (nums == null || nums.length == 0) { return null; } int len = nums.length...

2020-04-13 21:42:06 668

原创 二叉搜索树查找第K小的元素

class TreeNode { int val; TreeNode left; TreeNode right; TreeNode(int x) { val = x; }}public class Solution { /** * 查找第K小的元素 */ public int kthSmalles...

2020-04-12 22:21:37 514

原创 二叉树求两个节点最近公共祖先

class TreeNode { int val; TreeNode left; TreeNode right; TreeNode(int x) { val = x; }}public class Solution { /** * 求2个节点最近公共祖先 */ public TreeNode lo...

2020-04-12 22:19:02 248

原创 数组右移后二分查找

import java.util.Arrays;public class Temp { //右移数组m位 public static void shiftArray1(int[] data, int m) { int len = data.length; while (m-- > 0) { int temp = d...

2020-04-09 22:25:49 276

原创 矩阵从左上角到右下角的最小路径值

public class Temp { public static int minPathNum(int[][] data, int startI, int startJ, int endI, int endJ) { int sum = Integer.MAX_VALUE; int i = startI; int j = startJ;...

2020-04-08 12:34:18 1111

原创 约瑟夫环报数出列问题

public class Temp { public static void printYuesefuNum(int total, int k) { int[] data = new int[total]; for (int i = 0; i < total; i++) { data[i] = i + 1; }...

2020-04-06 20:14:58 390

原创 简单的LFU Cache实现

import java.util.HashMap;import java.util.Map;import java.util.TreeMap;class LFUCache { static class Node { private int key; private int value; private int frequency; ...

2020-04-05 18:41:15 383

原创 JDK常用类

ThreadPoolExecutorForkJoinPoolAbstractQueuedSynchronizerConcurrentHashMapConcurrentLinkedQueueConcurrentSkipListMapCopyOnWriteArrayListCopyOnWriteArraySetArrayBlockingQueueLinkedBlockingQueue...

2020-03-28 11:16:57 220

原创 求两个字符串的最大公共子串

public class Temp { public static String lcs(String a, String b) { if (a == null || b == null || a.length() == 0 || b.length() == 0) { return ""; } int aLen =...

2020-03-22 16:54:09 218

原创 简单的Trie前缀树实现

import java.util.LinkedList;import java.util.List;class TrieNode { List<TrieNode> children = new LinkedList<>(); boolean isEnd; char item = ' '; public TrieNode() { ...

2019-12-26 11:01:05 140

原创 简单的LRU Cache实现

class LRUCache { public static class Node { public int key; public int value; public Node pre; public Node next; public Node(int key, int value) { ...

2019-12-26 10:48:36 125

原创 简单的HashMap实现

class MyHashMap { private int sizeOfTable = 1024; private Node[] table = new Node[sizeOfTable]; private class Node { public int key; public int value; public Node...

2019-12-26 10:41:52 122

原创 Skip List基本操作

public class SkipList { public int height; public int size; public Random random = new Random(); public Node head = new Node(0, null, true); public static class Node { pu...

2019-12-25 14:28:55 168

原创 AVL树基本操作

public class AVLTree { public static class Node { public int data; public int height; public Node left; public Node right; public Node(int data) { ...

2019-12-21 21:08:29 198

原创 多线程交替打印数字

public class ThreadTest { private static int count = 1; public static void main(String[] args) throws InterruptedException { Object obj = new Object(); Runnable runnable = ()...

2019-11-27 15:46:36 205

原创 常用的工具

ASCII码:http://www.asciitable.com JSON格式化:http://www.bejson.com URL编码:http://tool.chinaz.com/tools/urlencode.aspx 在线HTML运行:http://codepen.io/anon/pen/NGMvJQ 常用对照表:http://tool.oschina.net/commons

2019-11-26 13:30:42 300 4

原创 elasticsearch读写文档模型

官网文档:https://www.elastic.co/guide/en/elasticsearch/reference/7.3/docs-replication.html简介  elasticsearch每个索引(index)由多个分片(shard)构成,每个分片又可以有多个副本(replica),这些副本共同组成了副本组(replication group),在添加或删除文档的时候副本组必...

2019-08-17 18:01:46 179

原创 elasticsearch v5.x 常用http接口

http://127.0.0.1:9200/_cluster/state http://127.0.0.1:9200/_cluster/health http://127.0.0.1:9200/_mappings http://127.0.0.1:9200/_segments http://127.0.0.1:9200/_template http://127.0.0.1:9200/_c...

2018-08-31 15:25:01 566

原创 elasticsearch倒排表压缩及缓存合并策略

官方详细的说明文档:https://www.elastic.co/blog/frame-of-reference-and-roaring-bitmaps一、Frame Of Reference   搜索引擎一项很重要的工作就是高效的压缩和解压缩一系列整数,这些整数指的就是包含特定词的文档id;每个词term有对应包含该词的doc id列表, term-&gt;doc id1,doc id2。...

2018-08-29 16:19:11 4441 4

原创 elasticsearch搜索过程分析

(一)通过HTTP请求调用搜索服务 示例:GET http://localhost:9200/index_test/_search{ &quot;query&quot;: { &quot;query_string&quot;: { &quot;default_field&quot;: &quot;title&quot;, &quot;query&quot;:

2018-08-29 16:07:43 4777

原创 elasticsearch索引数据的过程

(一)索引相关主要配置参数: action.auto_create_index index.mapper.dynamic index.number_of_shards index.number_of_replicas index.store.throttle.type index.store.throttle.max_bytes_per_sec index.queries.cache...

2018-08-29 14:49:13 5557

原创 elasticsearch discovery模块启动通信过程

elasticsearch是由Elasticsearch类的main方法启动的,首先会读取系统环境变量和虚拟机参数进行配置,参数环境配置后由Bootstrap类init方法负责主要的启动过程。 (1)、通过Enviroment的环境构建Node节点资源,加载插件,设置类的注入及绑定关系,有了Node实例,调用start方法后Node生命周期开始启动,通过injector.getInstance(...

2018-08-29 14:28:39 1499

原创 elasticsearch创建快照、恢复快照

(一)准备工作环境: elasticsearch 5.6.3 &amp;amp; repository-hdfs plugin centos 7 jdk1.8 hadoop 2.7.2配置hadoop环境,后续可通过浏览器查看hadoop信息: namenode 概况:http://localhost:50070 集群和应用信息:http://localhost:8088 节点管理:...

2018-08-29 10:45:03 2805 1

原创 elasticsearch整体结构示意图

请求处理: 主要模块: 主要模块说明:Transport Client/Node Client/REST API:三种访问es集群的方式Transport(Netty):通信模块,数据传输,底层采用netty框架Index、Search…:支持搜索,索引等常用操作Discovery:节点发现,集群之间通信的基石Plugins:很多服务以插件形式提供,官方和社区支持的...

2018-08-29 10:34:40 2671

原创 Intellij Idea编译Lucene源码

一、软件环境 ant 1.9.6 下载地址:http://ant.apache.org/ivy/download.cgi lucene 6.6.1 官网:https://lucene.apache.org/ jdk 1.8 二、编译源码 1,lucene 使用ant+ivy进行依赖管理,安装完ant后 直接执行 ant 命令:ant ,会报错 This build requires...

2018-08-29 10:31:37 3937

原创 Intellij Idea 运行Elasticsearch源码 v6.0.0

一、软件环境 Intellij Idea Elasticsearch 6.0.0,其它版本也一样 JDK:1.8 Gradle 官网:https://gradle.org/ 二、下载elasticsearch源码:https://github.com/elastic/elasticsearch 三、导入idea 1、配置阿里maven仓库,加速jar包下载 先不要导入idea,用n...

2018-08-29 10:23:16 2967

原创 java判断字符是否是汉字

public class Demo { public static boolean isChinese(char c) { Character.UnicodeBlock ub = Character.UnicodeBlock.of(c); if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS

2017-08-09 15:09:42 417

原创 汉字数字转阿拉伯数字

import org.apache.commons.lang3.StringUtils;import java.util.ArrayDeque;import java.util.ArrayList;import java.util.Deque;import java.util.HashMap;import java.util.List;import java.util.Map;public

2017-07-22 09:06:33 401

原创 求数组排序后相邻两个数的最大差值

import java.util.Arrays;import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNext()) {

2016-10-16 13:07:48 1272 1

原创 求一个数组中连续子数组的最大乘积

public class Solution { public int maxProduct(int[] nums) { if (nums == null || nums.length == 0) { return 0; } if (nums.length == 1) { return nums[0]

2016-10-08 17:34:15 1003

原创 全组合

import java.util.ArrayList;import java.util.List;public class Solution { public List<List<Integer>> subsets(int[] nums) { List<List<Integer>> result = new ArrayList<>(); result.add(

2016-09-29 00:16:03 265

原创 组合 N选K

import java.util.ArrayList;import java.util.Arrays;import java.util.List;public class Solution { public void add(int[] array, int[] nums, List<List<Integer>> result) { List<Integer> list =

2016-09-28 23:51:45 381

原创 全排列 去重 非字典序

import java.util.ArrayList;import java.util.HashSet;import java.util.List;import java.util.Set;public class Solution { public List<List<Integer>> permute(int[] nums) { List<List<Integer>

2016-09-28 22:59:09 303

原创 01背包

import java.util.Scanner;public class Main { public static void main(String argv[]) { Scanner in = new Scanner(System.in); while (in.hasNext()) { int n = in.nextInt();

2016-09-28 22:14:24 232

原创 全排列-字典序

import java.util.Scanner;public class Solution { static int count = 2; public static void swap(char[] arr, int i, int j) { char tmp = arr[i]; arr[i] = arr[j]; arr[j] = tm

2016-09-28 21:52:58 248

原创 旋转矩阵

import java.util.Arrays;public class Solution { //顺时针旋转90度 public void rotate(int[][] matrix) { for (int i = 0, j = matrix.length - 1; i < j; i++, j--) { int[] temp = matrix

2016-09-17 13:16:31 331

空空如也

空空如也

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

TA关注的人

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