题意描述 输入n个整数,找出其中最小的K个数。例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,。 解题思路 一、冒泡排序/选择排序 对数组进行排序,从数组中取出最小的k个数。不需要对数组全部排序,只需要找出前k个数即可。 二、快速排序 利用快速排序 划分 的思想, ...
分类:
其他好文 时间:
2020-04-18 22:49:10
阅读次数:
54
这是一个第三方库,可以处理xlsx格式的Excel文件。pip install openpyxl安装。如果使用Aanconda,应该自带了。 读取Excel文件 需要导入相关函数。 1 from openpyxl import load_workbook 2 3 # 默认可读写,若有需要可以指定wr ...
分类:
编程语言 时间:
2020-04-18 18:34:24
阅读次数:
58
This is the hard version of the problem. The difference is the constraint on the sum of lengths of strings and the number of test cases. You can make ...
分类:
编程语言 时间:
2020-04-18 14:10:40
阅读次数:
87
Problem : You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can ...
分类:
其他好文 时间:
2020-04-18 10:09:19
阅读次数:
67
说明 从本质上来讲,fold方法读取一种数据,然后返回给你另外一种。 fold和foldLeft和foldRight做的事同样的事情,仅有一点点不同。 fold val numbers = List(1, 2, 3, 4, 5) val res = numbers.fold(10) { (z, i)... ...
分类:
其他好文 时间:
2020-04-18 09:32:45
阅读次数:
47
给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。 如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。 您可以假设除了数字 0 之外,这两个数都不会以 0 开头。 来源:力扣(LeetCode)链接: ...
分类:
其他好文 时间:
2020-04-18 09:27:22
阅读次数:
62
"CodeForces 55D Beautiful numbers" 一句话题意:有T组询问,每次询问区间[l, r]中的beautiful number有多少。beautiful number是指这个数可以被组成它的数字整除。例如15是beautiful number,因为15可以被1整除,也可以 ...
分类:
其他好文 时间:
2020-04-17 18:39:23
阅读次数:
57
Problem : Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one c ...
分类:
其他好文 时间:
2020-04-17 00:23:13
阅读次数:
77
You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1' ...
分类:
其他好文 时间:
2020-04-15 15:17:52
阅读次数:
68