码迷,mamicode.com
首页 >  
搜索关键字:sorted    ( 5925个结果
[leetcode 16] 最接近的三数之和
给定一个包括n的整数数组nums,和一个目标值target。找出nums中的三个整数,使得它们的和与target最接近,返回这三个数的和。假定每次输入只存在一个答案。 示例: nums = [-1,2,1,-4] 和 target = 1 与 target 最接近的三个数的和为2. (-1+2+1= ...
分类:其他好文   时间:2019-02-02 11:14:27    阅读次数:191
build-in函数sorted()的应用
首先help(sorted)一下,得到如下信息: 此函数有三个参数: iterable 可迭代的list key 决定按照排列的对象 reverse--决定是升序还是降序 默认是按照升序对列表元素进行排列 简单的例子: 但是当我们进行复杂的排序时,key就能大显身手了! 比如我们将以下元组按照优先级 ...
分类:其他好文   时间:2019-02-01 18:06:39    阅读次数:158
LeetCode-5-Longest Palindromic Characters
算法描述: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Example 1: Examp ...
分类:其他好文   时间:2019-02-01 14:12:17    阅读次数:161
LeetCode-81-Search in Rotated Sorted Array II
算法描述: Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1, ...
分类:其他好文   时间:2019-02-01 13:03:01    阅读次数:148
leetcode 21. Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Example: ...
分类:其他好文   时间:2019-01-31 22:59:42    阅读次数:198
4Sum - LeetCode
[toc] 题目链接 " Merge Two Sorted Lists LeetCode" 注意点 和3Sum那道题一样 解法 解法一:在 "3Sum" 的基础上再加一层循环即可。时间复杂度为O(n^3) 解法二:看了评论得到的思路。先二重循环,将所有可能出现的两数之和的值map保存。然后再二重循环 ...
分类:其他好文   时间:2019-01-31 15:48:44    阅读次数:146
Python中操作Redis
一 Rdis基本介绍 redis是一个key-value存储系统。它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)、zset(sorted set --有序集合)和hash(哈希类型)。这些数据类型都支持push/pop、add/remove及取交集并 ...
分类:编程语言   时间:2019-01-31 12:59:42    阅读次数:231
#Leetcode# 692. Top K Frequent Words
https://leetcode.com/problems/top-k-frequent-words/ Given a non-empty list of words, return the k most frequent elements. Your answer should be sorted ...
分类:其他好文   时间:2019-01-31 00:15:24    阅读次数:161
#Leetcode# 378. Kth Smallest Element in a Sorted Matrix
https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/ Given a n x n matrix where each of the rows and columns are sorted in ascending ...
分类:其他好文   时间:2019-01-30 21:45:57    阅读次数:190
Merge Two Sorted Lists - LeetCode
[toc] 题目链接 " Merge Two Sorted Lists LeetCode" 注意点 两个链表长度可能不一致 解法 解法一:先比较两个链表长度一致的部分,多余的部分直接加进答案链表即可。时间复杂度为O(n) 小结 通常链表开头的第一个结点不存放数据,或者是不用来存放数据仅仅是作为一个向 ...
分类:其他好文   时间:2019-01-30 14:23:26    阅读次数:114
5925条   上一页 1 ... 83 84 85 86 87 ... 593 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!