命令总结window&Linux

收到## window

查看java进程 jps
杀进程 taskkill /f /pid

(1)再次提高性能。mater-work 模式,拆分任务 ,把一个任务继续拆分多个线程执行,并行执行,提高cpu执行效率 Fork-Join框架实现。
(2)空间换时间。持久化新进来,等于加大等待时间,通过对处理任务进行持久化到第三方组件上,例如消息队列,缓存。

在这里插入图片描述

package setMessage;

/**
 * Created with IntelliJ IDEA.
 * User: lixiao
 * Created Date: 2021/1/20 23:21
 */
public class Main {


    public static void main(String[] args) {


        int result=0;
        for (int k = 1; k <8 ; k++) {
            int maxN= (int) Math.pow(2,k-1);
            for (int n = 1; n < maxN+1; n++) {
                result=mouth(k,n);
                System.out.print(result);
            }
            System.out.println();
        }

        System.out.println(                          mouth(3,3));

    }


    public static int mouth(int k,int n){
        int result=0;
        boolean flag=true;
        int moddle=0;
        int n1=n;

        for (int i = k; i > 2; i--) {
             moddle = (int) Math.pow(2, i-2);
             if(n1>moddle){
                n1=n1-moddle;
                flag=!flag;
             }else if(n1==moddle){
                 result=i%2;
                 n1=0;
                 break;
             }
        }
        if(n1==1){
           result=0;
        }if(n1==2){
            result=1;
        }if(n==0){
            result=1;
        }
        if(!flag){
            result=1-result;
        }


        return result;
    }

}
package algorithm;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @date 2021/1/22 14:44
 */
public class Mian {

    public class Node {
        public Node parent;
        public Node l;
        public Node r;

        public Node(Node parent, Node l, Node r) {
            this.parent = parent;
            this.l = l;
            this.r = r;
        }

        public Node getParent() {
            return parent;
        }

        public Node getL() {
            return l;
        }

        public Node getR() {
            return r;
        }
    }

    public Node Common(Node node1, Node node2) {

        List<Node> nodeList1 = new ArrayList<>();

        List<Node> nodeList2 = new ArrayList<>();

        while (node1.parent != null) {
            nodeList1.add(node1);
            node1 = node1.parent;
        }
        while (node2.parent != null) {
            nodeList2.add(node2);
            node1 = node2.parent;
        }

        Collections.reverse(nodeList1);
        Collections.reverse(nodeList2);

        List<Node> nodeList3 = new ArrayList<>();
        List<Node> nodeList4 = new ArrayList<>();

        if (nodeList1.size() > nodeList2.size()) {
            nodeList4 = nodeList3 = nodeList1;
        } else {
            nodeList4 = nodeList3 = nodeList2;
            nodeList2 = nodeList1;
        }

        nodeList3.removeAll(nodeList2);

        Node parentNex = nodeList3.get(0);
        if (nodeList4.size() == 1) {
            return nodeList4.get(0);
        } else {
            int nex = nodeList4.indexOf(parentNex);
            return nodeList4.get(nex - 1);
        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值