Comparable Comparator 区别与联系 举栗子: Comparable Demo 类可以通过实现Comparable接口来扩展排序功能 实现了Comparable的类可以直接调用list的sort和Collections.sort来实现排序 Comparator Demo 创建一个实 ...
分类:
其他好文 时间:
2018-11-04 23:58:38
阅读次数:
295
这里强烈推荐一个博主写的二分搜索总结:http://www.cnblogs.com/grandyang/p/6854825.html 参考链接: https://leetcode.com/problems/find-first-and-last-position-of-element-in-sort ...
分类:
其他好文 时间:
2018-11-04 14:18:46
阅读次数:
241
分析 难度 易 来源 https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/ 题目 Given an array where elements are sorted in ascending order, c ...
分类:
其他好文 时间:
2018-11-04 12:36:32
阅读次数:
189
这是悦乐书的第 161 次更新,第 163 篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第20题(顺位题号是88)。给定两个排序的整数数组nums1和nums2,将nums2中的元素合并到nums1中,并且作为一个排序的数组。在nums1和nums2中初始化的元素个数 ...
分类:
编程语言 时间:
2018-11-04 11:11:14
阅读次数:
178
题目链接:https://leetcode.com/problems/rotate-list/description/ Given a sorted linked list, delete all duplicates such that each element appear only once. ...
分类:
其他好文 时间:
2018-11-04 01:52:25
阅读次数:
157
这道题目很经典,本人表示在面试时遇见过,要求复杂度为O(logn),很显然必须用二分查找,但是旋转导致数组并非从左到右都是有序的,因此我们在查找时需要做判断,我们找打的终点左边或者右边至少一边是有序的;如果中间数小于最右边的数字,则右半段是有序的;如果中间数字大于最右边数字,则左半段是有序的,参考下 ...
分类:
其他好文 时间:
2018-11-03 23:08:34
阅读次数:
242
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted i ...
分类:
其他好文 时间:
2018-11-03 16:28:13
阅读次数:
210
Redis 数据类型 Redis支持五种数据类型:string(字符串),hash(哈希),list(列表),set(集合)及zset(sorted set:有序集合)。 String(字符串) string 是 redis 最基本的类型,你可以理解成与 Memcached 一模一样的类型,一个 k ...
分类:
其他好文 时间:
2018-11-03 15:21:59
阅读次数:
181
Suppose an array sorted in ascending order 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]). Y ...
分类:
其他好文 时间:
2018-11-03 13:56:29
阅读次数:
124
这是悦乐书的第160次更新,第162篇原创 01 前情回顾 昨晚的爬楼梯算法题,有位朋友提了个思路,使用动态规划算法。介于篇幅问题,这里不细说动态规划算法,以后会在数据机构和算法的理论知识里细说。 昨晚的三个解法中,根据测试数据和结果,第三种解法是最优的,但是还能不能更进一步呢?经过推导,我们得知当 ...
分类:
编程语言 时间:
2018-11-03 10:25:38
阅读次数:
131