假设堆中存int类型的数据,直接一波PriorityQueue<Integer> queue = new PriorityQueue<>();即可完成小顶堆的构建,直接A了,因为默认的用new创建优先队列对象为小顶堆。 但是如何完成大顶堆的构建呢? 先介绍一种简洁的写法,利用lambda表达式来操作 ...
分类:
其他好文 时间:
2020-03-17 19:20:54
阅读次数:
140
来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/roman-to-integer 罗马数字包含以下七种字符: I, V, X, L,C,D 和 M。 字符 数值I 1V 5X 10L 50C 100D 500M 1000例如, 罗马数字 2 写做 ...
分类:
其他好文 时间:
2020-03-17 16:46:09
阅读次数:
45
Numbers can be regarded as product of its factors. For example, 8 = 2 x 2 x 2; = 2 x 4. Write a function that takes an integer n and return all possib ...
分类:
其他好文 时间:
2020-03-17 10:23:21
阅读次数:
66
0-100求和:class MyTask extends RecursiveTask<Integer>{ public static final int ADJAST_VALUE = 10; private int begin; private int end; private int result ...
分类:
其他好文 时间:
2020-03-16 23:31:24
阅读次数:
67
Java内置了API: Integer.toBinaryString(); 先看源码是怎么写的 java public static int numberOfLeadingZeros(int i) { // HD, Figure 5 6 if (i == 0) return 32; int n = ...
分类:
其他好文 时间:
2020-03-16 19:09:21
阅读次数:
92
/** * Log any invocation timeout, but don't stop server from running * 服务于服务提供者 */ @Activate(group = Constants.PROVIDER) public class TimeoutFilter im ...
分类:
其他好文 时间:
2020-03-16 17:34:03
阅读次数:
56
1.举例sort和sorted对列表排序,list=[0,-1,3,-10,5,9] #列表排序 list=[0,-1,3,-10,5,9] list.sort(reverse=False) print("list.sort在list基础上修改,无返回值",list) list=[0,-1,3,-1 ...
分类:
编程语言 时间:
2020-03-16 14:54:34
阅读次数:
83
Design a stack which supports the following operations. Implement the CustomStack class: CustomStack(int maxSize) Initializes the object with maxSize ...
分类:
其他好文 时间:
2020-03-16 09:53:58
阅读次数:
54
手动创建:环境描述:一台机器启动六个节点,3个主节点,3个从节点。安装:tar-zxvfredis-3.2.10.tar.gzmvredis-3.2.10/usr/local/redisyuminstallgcc*tcl-ymake&&maketest修改配置文件:vi/usr/local/redis/redis.conf**要改的地方**daemonizeyesport7000c
分类:
其他好文 时间:
2020-03-16 09:39:31
阅读次数:
51
1. rand7生成rand10 1 # The rand7() API is already defined for you. 2 # def rand7(): 3 # @return a random integer in the range 1 to 7 4 5 class Solution( ...
分类:
其他好文 时间:
2020-03-16 09:38:13
阅读次数:
56