This commit is contained in:
fanxb 2021-07-15 16:44:33 +08:00
parent 59820d39da
commit 77e3e9a244
8 changed files with 105 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package com.fanxb.common;
import java.util.Arrays;
/**
* 题目地址 https://leetcode-cn.com/problems/partition-labels/
* 解题思路首先遍历一次字符串记录每个字母最后出现的位置
* 然后再遍历一遍记录当前字符串的开始位置start,结束位置end. 当第i个字母的结束位置end时end=第i个字母的结束位置知道i=end说明当前位置为字符串的结束位置
*
* @author fanxb
* Date: 2020/6/9 15:10
*/
public class Q1846 {
public int maximumElementAfterDecrementingAndRearranging(int[] arr) {
Arrays.sort(arr);
arr[0] = 1;
for (int i = 1; i < arr.length; i++) {
if (arr[i] - arr[i - 1] > 1) {
arr[i] = arr[i - 1] + 1;
}
}
return arr[arr.length - 1];
}
public static void main(String[] args) {
System.out.println(new Q1846().maximumElementAfterDecrementingAndRearranging(new int[]{2,2,1,2,1}));
}
}

View File

@ -0,0 +1,6 @@
data/main/*
!data/main/.gitkeep
data/slave1/*
!data/slave1/.gitkeep
data/slave2/*
!data/slave2/.gitkeep

View File

@ -0,0 +1,5 @@
bind 0.0.0.0
port 11002
# 开启集群模式
cluster-enabled yes
cluster-config-file "redis-node2.conf"

View File

@ -0,0 +1,5 @@
bind 0.0.0.0
port 11003
# 开启集群模式
cluster-enabled yes
cluster-config-file "redis-node3.conf"

View File

@ -0,0 +1,5 @@
bind 0.0.0.0
port 11004
# 开启集群模式
cluster-enabled yes
cluster-config-file "redis-node4.conf"

View File

@ -0,0 +1,5 @@
bind 0.0.0.0
port 11005
# 开启集群模式
cluster-enabled yes
cluster-config-file "redis-node5.conf"

View File

@ -0,0 +1,5 @@
bind 0.0.0.0
port 11006
# 开启集群模式
cluster-enabled yes
cluster-config-file "redis-node6.conf"

View File

@ -0,0 +1,45 @@
version: "3"
services:
node1:
image: redis:6.2.4
volumes:
- ./config:/usr/local/etc/redis
command: ["redis-server","/usr/local/etc/redis/node1.conf"]
network_mode: "host"
node2:
image: redis:6.2.4
volumes:
- ./config:/usr/local/etc/redis
command: ["redis-server","/usr/local/etc/redis/node2.conf"]
network_mode: "host"
node3:
image: redis:6.2.4
volumes:
- ./config:/usr/local/etc/redis
command: ["redis-server","/usr/local/etc/redis/node3.conf"]
network_mode: "host"
node4:
image: redis:6.2.4
volumes:
- ./config:/usr/local/etc/redis
command: ["redis-server","/usr/local/etc/redis/node4.conf"]
network_mode: "host"
node5:
image: redis:6.2.4
volumes:
- ./config:/usr/local/etc/redis
command: ["redis-server","/usr/local/etc/redis/node5.conf"]
network_mode: "host"
node6:
image: redis:6.2.4
volumes:
- ./config:/usr/local/etc/redis
command: ["redis-server","/usr/local/etc/redis/node6.conf"]
network_mode: "host"