摘要: ####单链表的基本操作: 1、单链表反转 2、链表中环的检测 3、两个有序链表的合并 4、删除倒数第K个结点 5、求链表的中间结点 ####编写链表代码的注意事项: 1、如果链表为空时,代码是否能正常工作? 2、如果链表只包含一个结点时,代码是否能正常工作? 3、如果链表只包含两个结点时,代码是否 阅读全文
posted @ 2020-04-06 16:48 limaodeng 阅读(438) 评论(0) 推荐(0)
摘要: ####链表实现回文判断 这篇文章是利用链表的反转实现回文的判断。 package com.datastructure.linkedlist; /** * 回文判断 * @Auther: dlm * @Date: 2020/4/6 11:39 */ public class Plalindrome 阅读全文
posted @ 2020-04-06 11:46 limaodeng 阅读(294) 评论(0) 推荐(0)
摘要: ####数组的内存分布 ####一维数组的寻址公式 a[i]_address = base_address + i * data_type_size 其中data_type_size表示数组中每个元素的大小。比如数组中存储的是int类型数据,所以data_type_size就为4个字节。 ####二 阅读全文
posted @ 2020-04-04 15:29 limaodeng 阅读(216) 评论(0) 推荐(0)
摘要: ####单链表 ####双向链表 ####循环链表 ####双向循环链表 ####链表与数据的内存分布 ####链表与数组的时间复杂度对比 ####单链表的基本操作 package com.datastructure.linkedlist; /** * @Auther: dlm * @Date: 2 阅读全文
posted @ 2020-04-04 15:21 limaodeng 阅读(130) 评论(0) 推荐(0)
摘要: 其实,空间复杂度比时间复杂度相对来说容易分析得多。 下面这段代码中,只有第三行申请的空间为 n ,其他代码申请的空间都是常数阶。因此这段代码的空间复杂度为 O(n)。 其实,我们常见的空间复杂度主要有O(1)、O(n)、O(n2 )。 像O(logn)、O(nlogn)这样的对数阶复杂度平时基本遇不 阅读全文
posted @ 2020-04-04 12:28 limaodeng 阅读(186) 评论(0) 推荐(0)
摘要: 这篇文章并不会讲时间复杂度的理论知识,而是通过讨论分析几种经典的时间复杂度,从而使我们能够求解平常开发中遇到的代码的时间复杂度。 ####时间复杂度分析方法: #####1、循环执行次数最多的代码 int cal(int n) { int sum = 0; int i = 1; for (; i < 阅读全文
posted @ 2020-04-04 12:07 limaodeng 阅读(434) 评论(0) 推荐(0)
摘要: #####欢迎关注个人公众号,可直接扫描以下二维码或微信搜索“阿毛聊技术”。 阅读全文
posted @ 2020-03-17 00:34 limaodeng 阅读(231) 评论(0) 推荐(0)
摘要: 1.题目描述 英文版: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were in 阅读全文
posted @ 2020-02-24 21:40 limaodeng 阅读(115) 评论(0) 推荐(0)
摘要: 1.题目描述 英文版: Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's 阅读全文
posted @ 2020-02-24 21:20 limaodeng 阅读(88) 评论(0) 推荐(0)
摘要: 1.题目描述 英文版: 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, 阅读全文
posted @ 2020-02-23 19:59 limaodeng 阅读(109) 评论(0) 推荐(0)