技巧一:字典排序 在python的中,字典里的元素(键值对)是没有排列顺序的,因此想要对字典里的元素进行排序的想法是错误的。但如果我们想要按键或值的顺序查看键值对,可以使用sorted函数进行排序,再将结果打印出来即可。 d = {'刘一':22, '陈二':20, '张三':15, '李四':19 ...
分类:
编程语言 时间:
2021-04-19 15:39:07
阅读次数:
0
range() 函数 日常工作中,range() 应该非常熟悉了,它可以生成一个迭代对象,然后可以使用 list() 将它转成一个 list # 判断是不是迭代对象 print(isinstance(range(0, 10), Iterable)) # 生成列表 lists = list(range ...
分类:
编程语言 时间:
2021-04-16 11:49:05
阅读次数:
0
merge函数的作用是:将两个已经排好序的序列合并为一个有序的序列。 函数参数:merge(first1,last1,first2,last2,result,compare); firs1t为第一个容器的首迭代器,last1为第一个容器的末迭代器; first2为第二个容器的首迭代器,last2为容 ...
分类:
其他好文 时间:
2021-04-16 11:46:46
阅读次数:
0
题目: Implement a function that receives two IPv4 addresses, and returns the number of addresses between them (including the first one, excluding the la ...
分类:
其他好文 时间:
2021-04-15 12:16:50
阅读次数:
0
一.排序: 1.slice切片( ::-1) 2.reversed( ) 3.sorted( ,reverse=True)) 字母数字不可同时存在。默认为False升序,True降序。 4.filter(function,iterable) 二.常用 1.sum() 2.max() 3.min() ...
分类:
编程语言 时间:
2021-04-15 11:57:56
阅读次数:
0
题目来源 Full Binary Tree Description In computer science,a binary tree is a tree data structure in which each node has at most two children. Consider an ...
分类:
其他好文 时间:
2021-04-13 12:02:15
阅读次数:
0
【python】Leetcode每日一题-寻找旋转排序数组中的最小元素2 ...
分类:
编程语言 时间:
2021-04-09 13:27:35
阅读次数:
0
Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order. Example 1: I ...
分类:
其他好文 时间:
2021-04-08 13:55:44
阅读次数:
0
仅供自己学习 思路: 思路比较简单,但要注意细节处理。 一开始就是想遍历寻找nums[i]<nums[i-1]获得旋转点,然后对这两侧的数组分别使用二分搜索,但是一直报错,找不到原因。 根据题解二分可知二分的本质是二段性,而非单调性。只要一段满足某个性质,另外一段不满足这个性质就可以用二分。 对于一 ...
分类:
其他好文 时间:
2021-04-08 13:18:01
阅读次数:
0
描述 输入两个递增排序的链表,合并这两个链表并使新链表中的节点仍然是递增排序的。 public ListNode mergeTwoLists(ListNode l1, ListNode l2) { //设置虚拟头结点 ListNode res = new ListNode(-1); ListNode ...
分类:
编程语言 时间:
2021-04-07 10:34:17
阅读次数:
0