搜索长度未知的有序数组。题目给了一个数组和一个target数字,如果你能在input数组中找到target,就输出其index,否则return -1。例子, Example 1: Input: array = [-1,0,3,5,9,12], target = 9 Output: 4 Explan ...
分类:
其他好文 时间:
2020-04-29 10:54:54
阅读次数:
81
题目描述 将给定的链表中每两个相邻的节点交换一次,返回链表的头指针例如,给出1->2->3->4,你应该返回链表2->1->4->3。你给出的算法只能使用常量级的空间。你不能修改列表中的值,只能修改节点本身。 Given a linked list, swap every two adjacent ...
分类:
其他好文 时间:
2020-04-29 00:52:16
阅读次数:
76
题目描述 合并k个已排序的链表并将其作为一个已排序的链表返回。分析并描述其复杂度。 Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 思路:合并k路有序 ...
分类:
其他好文 时间:
2020-04-28 23:13:44
阅读次数:
64
字典:{} 扩起来,以兼职对形式存储的容器型数据类型键必须是不可变的数据类型值可以是任意类型python3.5之前是无序的,3.6会按照初次建立的顺序排列,3.7以后是有序的优点:查询速度快,存储关联性的数据;缺点:以空间换时间方式一:dict = dict((('one', 1), ('two', ...
分类:
编程语言 时间:
2020-04-28 13:04:46
阅读次数:
82
GANs Trained by a Two Time-Scale Update Rule Converge to a Local Nash Equilibrium https://github.com/bioinf-jku/TTUR Abstract 生成式对抗网络(GANs)擅长创建具有复杂模型的 ...
分类:
其他好文 时间:
2020-04-27 17:07:42
阅读次数:
77
使用lambda匿名函数来实现。>>> dic1 = {'a':1,'b':2,'e':5,'d':4,'c':3}>>> result = sorted(dic1.items(), key = lambda x :(x[1]))>>> result[('a', 1), ('b', 2), ('c'... ...
分类:
编程语言 时间:
2020-04-27 15:15:10
阅读次数:
62
Given two binary search trees, return True if and only if there is a node in the first tree and a node in the second tree whose values sum up to a giv ...
分类:
其他好文 时间:
2020-04-27 13:22:13
阅读次数:
61
Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is t ...
分类:
其他好文 时间:
2020-04-26 19:22:16
阅读次数:
72
2020 04 26 "原题链接" + 思路 题意就是寻找两个有序数组的中位数。第一反应可能会先把两个数组合并然后再找中位数,但是显然我们没有必要把合并后的数组存起来,只要依次搜索,得到最中间的一个或两个就可。美中不足的是它的时间复杂度为 。 为了达到题目中时间复杂度为 的要求,我们可以使用二分(其 ...
分类:
编程语言 时间:
2020-04-26 18:32:01
阅读次数:
66
Problem Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum ...
分类:
其他好文 时间:
2020-04-26 12:31:47
阅读次数:
51