sort

服务器磁盘日志打满

一大早服务器磁盘被日志打满。 简单排查了一下,列几个小朋友试过的查找目标日志文件的命令。某个目录及子目录下的十个最大文件find . -printf '%s %pn'|sort -nr|head -n 表示对结果以数值进行排序-r 表示逆序head 表示取结果的前十行只查找当前目录find . -maxdepth 1 -printf '%s %pn'|sort -nr|he

148. Sort List

题目:Sort a linked list in O(n log n) time using constant space complexity.解答:(对于discuss中第二个最优解的解释)根据时间复杂度的要求,很容易想到应该用merge sort的方法来做,那么就有两个步骤,分和法。先把整个list分成两部分,这里可以用找中间值的方法,在找中间值的同时,标记一下中间值

179. Largest Number

这道题开始想容易陷入一个误区:我要怎么比较这两个单独的数,使得它们拼起来的结果最大呢?然而如果真的仔细比较这两个数最后得出一个结论,代码会很长,楼主已经试过了。。。后来转念一想,直接比较两个数拼成的结果不就好了,长度一样,所以省去了很多麻烦。程序如下: public String largestNumber(int[] nums) { //直接暴力地把两个数合成一个Stri

75. Sort Colors

题目:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use th

147. Insertion Sort List

注意新的list跟原来的list是不相连的,然后把各个状态的点记录好就行: public ListNode insertionSortList(ListNode head) { if (head == null || head.next == null) return head;//We started a new list here, not the original o

274. H-Inde

题目:Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to the definition of h-index on Wik

164. Maimum Gap

题目:Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 if the array contains less than 2 e

查看文件占用情况

sudo du -sh /* sudo du -sh /var/lib/* |sort -h -r | head -n 10 sudo find / -type f -size +10G sudo du -a / | sort -n -r | head -n 10 du -a /var | sort -n -r | head -n 10 关键字:linux, sudo,