首页 > TAG信息列表 > doubleList

146. LRU 缓存

class LRUCache { class DoubleList{ public int key, val; public DoubleList prev, next; public DoubleList(){} public DoubleList(int key, int val){ this.key = key; this.val = val; } }

获取List中的最大、最小、平均值

最大、最小值 Double max = doubleList.stream().max(Comparator.comparingDouble(Double::doubleValue)).orElse(null); Double min = doubleList.stream().min(Comparator.comparingDouble(Double::doubleValue)).orElse(null); Double max = doubleList.stream().mapToDoubl

使用stream求数组中的平均值

通过数组和流的转换来求平均值: public class DoubleStream { public static void main(String[] args) { List<Double> doubleList = new ArrayList<>(); doubleList.add(1.3); doubleList.add(2.2); doubleList.add(3.2); doubl

去除重叠区间

题目:去除区间中重叠的部分 intput1 :  [[1, 2], [1, 3], [2, 3], [3, 4]]output1:  [[1, 2], [2, 3], [3, 4]]input2:    [[1, 2], [1, 2], [1, 2]]output2:  [[1, 2]]input3:    [[1, 2], [2, 3]]output3:  [[1, 2], [2, 3]] 思路: 将区间进行排序,从小到大,获取第一个区间