单例方式 通过类的绑定方法 通过装饰器 通过元类 通过模块: sort 与 sorted 区别: 1. sort 是应用在 list 上的方法,属于列表的成员方法,sorted 可以对所有可迭代的对象进行排序操作。 2. ist 的 sort 方法返回的是对已经存在的列表进行操作,而内建函数 sor ...
分类:
其他好文 时间:
2019-09-12 13:30:24
阅读次数:
63
Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Return 0 if the array contains less than 2 el ...
分类:
其他好文 时间:
2019-09-11 09:25:35
阅读次数:
77
题目链接:Almost Sorted Array 不用任何算法的做法:样例:1 3 6 5 7 8 9 9 8 7 5 6 3 2 2 7 1 1 AC代码: 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #incl ...
分类:
其他好文 时间:
2019-09-10 20:49:10
阅读次数:
91
26. Remove Duplicates from Sorted Array 从已排序的数组中移除重复元素 https://leetcode.com/problems/remove-duplicates-from-sorted-array/ 题目:给定已排序数组nums,移除重复项,使每个元素只出 ...
分类:
编程语言 时间:
2019-09-10 15:03:20
阅读次数:
120
Q1 找第k小的数 设计一个平均时间为O(n)的算法,在n(1输入格式: 输入有两行: 第一行是n和k,0输出格式: 输出第k小的数 输入样例: 在这里给出一组输入。例如: 输出样例: 在这里给出相应的输出。例如: Notes (1) Explicitly write at the end of t ...
分类:
其他好文 时间:
2019-09-08 10:08:52
阅读次数:
124
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sh ...
分类:
其他好文 时间:
2019-09-05 00:55:11
阅读次数:
82
Redis支持的五种数据类型 字符串 (string) 字符串列表 (list) 散列 (hash) 字符串集合 (set) 有序字符串集合 (sorted set) key(键) keys 获取所有的key select 0 选择第一个库 move myString 1 将当前的数据库key移动到 ...
分类:
其他好文 时间:
2019-09-04 16:26:45
阅读次数:
86
public class MergeTwoSortedLists { /* 解法一:迭代 */ public ListNode mergeTwoLists(ListNode l1, ListNode l2) { if (l1==null) return l2; if (l2==null) ... ...
分类:
其他好文 时间:
2019-09-03 22:16:49
阅读次数:
93
Redis数据类型 Redis支持五种数据类型:String(字符串),Hash(哈希),List(列表),Set(集合)及Zset(sorted set:有序集合)。 五种数据类型使用场景 连接redis-server Redis的key 常规操作(更多操作https://www.runoob.c ...
分类:
其他好文 时间:
2019-09-03 22:08:48
阅读次数:
92
# 如何根据字典“键”或“键值”进行不同顺序的排序?dic = {'c': 1, 'a': 3, 'b': 2}# 按键升序排序key_asc = sorted(dic.items(), key=lambda item:item[0], reverse=False)print(key_asc)# 结 ...
分类:
编程语言 时间:
2019-09-03 13:25:34
阅读次数:
97