题目描述 输入n个整数,找出其中最小的K个数。例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4。 思路1 可以先将这n个整数升序排序,然后输出前k个数字即可。下面的代码使用快速排序: 该算法的时间复杂度为O(nlogk),为3个算法中时间复杂度最低的。该算法无需对数 ...
分类:
其他好文 时间:
2020-03-16 22:01:26
阅读次数:
73
You are given an array aa consisting of nn integers. Your task is to determine if aa has some subsequence of length at least 33 that is a palindrome. ...
分类:
其他好文 时间:
2020-03-14 23:35:49
阅读次数:
96
轮询 根据Nginx配置文件中的顺序,每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器 down 掉,能自动剔除。 upstream web { server server1; server server2; } 最少连接 Web 请求会被转发到连接数最少的服务器上。least_conn ...
分类:
其他好文 时间:
2020-03-14 16:49:52
阅读次数:
51
今天在启动微服务项目的时候报错: Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'budgetServiceImpl': Unsat ...
分类:
其他好文 时间:
2020-03-11 01:25:28
阅读次数:
85
一.定义 迪米特法则,又叫最少知道原则(Least Knowledge Principle) 一个类应该保持对其他类最少的了解 也就是说:只与直接朋友交流,不和陌生人交流 朋友:每个对象都会与其他对象有耦合关系,只要两个对象之间有耦合关系,我们称之为朋友 耦合分为:依赖、关联、组合、聚合等等,我们称 ...
分类:
编程语言 时间:
2020-03-08 17:15:21
阅读次数:
80
"题目" DP 险过。 dp[i][j] :means it need remove at least dp[i][j] characters to get vaild parenthese from position i to postion j in string. vector str[i][ ...
分类:
其他好文 时间:
2020-03-07 12:52:52
阅读次数:
52
1 """ 2 Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must ...
分类:
其他好文 时间:
2020-03-07 09:40:06
阅读次数:
81
1 """ 2 Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. 3 get(key) ...
分类:
系统相关 时间:
2020-03-06 22:05:50
阅读次数:
100
什么是LRU LRU(Least recently used,最近最少使用)算法根据数据的历史访问记录来进行淘汰数据,其核心思想是“如果数据最近被访问过,那么将来被访问的几率也更高” 距离现在最早使用的会被我们替换掉。不够形象的话我们看下面的例子。 size=3的缓存淘汰实现: 在插入元素1的时候, ...
分类:
编程语言 时间:
2020-03-06 15:53:35
阅读次数:
74
The Castle OpenJ_Bailian - 1164 1 2 3 4 5 6 7 ############################# 1 # | # | # | | # ##### ##### # ##### # 2 # # | # # # # # # ##### ##### ## ...
分类:
其他好文 时间:
2020-03-03 12:45:41
阅读次数:
73