使用数组和链表实现栈和队列的复杂度分析 抽象数据类型(abstract data type,ADT)是带有一组操作的一些对象的集合1 表ADTA1,A2,⋯ ,ANA_1,A_2,\cdots,A_NA1,A2,⋯,AN 如上,这是一个大小为N的表。当然,若N为0,则称其为空表。 对于除空表以外的任何表,A1可以看作是A2的前驱,而A2则是A1的后继。在一个表中,表中第一个元素是A1...
深入了解Cookie 1. 前言朋友问我cookie是什么,用来干什么的,可是我居然无法清楚明白简短地向其阐述cookie,这不禁让我陷入了沉思:为什么我无法解释清楚,我对学习的方法产生了怀疑!在知乎上看到有人推荐使用费尔曼学习技巧,于是在重新学习cookie的过程中使用了该技巧来试验,效果有待验证!在学习一个新的知识点前,我们应该明白自己的学习目标,要带着疑问去学习,该小节须要了解: 1. 什么是c...
队列的基本概念以及java实现队列 队列队列的基本概念队列的抽象数据类型顺序队列 构造函数 入队 出队 查询front 获取队列长度 链式队列 构造函数 入队 出队 查询front 获取队列长度 循环列队 构造函数 入队 出队 查询front 获取循环队列的大小 判断队列是否为空 判断队列是否满 代码传送门,欢迎star:https://github.com/mcrwayfun/...
队列的基本概念以及java实现队列 队列队列的基本概念队列的抽象数据类型顺序队列 构造函数 入队 出队 查询front 获取队列长度 链式队列 构造函数 入队 出队 查询front 获取队列长度 循环列队 构造函数 入队 出队 查询front 获取循环队列的大小 判断队列是否为空 判断队列是否满 代码传送门,欢迎star:https://github.com/mcrwayfun/...
HashMap中的indexFor是如何计算的 HashMap中的indexFor方法分析分析java7的HashMap源码的时候,其用indexFor来计算entry对象在table数组中的索引值 static int indexFor(int h, int length) { // assert Integer.bitCount(length) == 1 : "length must be a non-ze...
栈的基本概念以及java实现栈 栈栈的基本概念栈的抽象类型顺序栈 构造函数 压栈 出栈 查询栈顶元素 判断栈是否为空 清空栈链式栈 构造函数 压栈 出栈 查询栈顶元素 判断栈是否为空 清空栈 顺序栈与链式栈的比较代码传送门,欢迎star:https://github.com/mcrwayfun/java-data-structure1. 栈的基本概念栈可以定义为只允许在表的...
java基本类型的转换分析 前言java有8种基本类型,分别有 基本数据类型 基本数据类型 byte char short float int double long boolean在java程序中,不同的类型需要进行转换。而转换有两种方式:自动转换和强制转换1. 自动类型的转换java中所有数值类型都可以互相转换,如下图所示:...
Baseball Game Baseball GameDescriptionYou’re now a baseball game point recorder.Given a list of strings, each string can be one of the 4 following types:Integer (one round’s score): Directly represents t...
First Bad Version First Bad VersionDescriptionYou are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each...
Valid Anagram Valid AnagramDescriptionGiven two strings s and t , write a function to determine if t is an anagram(相同字母异序词) of s.Example 1:Input: s = "anagram", t = "nagaram"Output: trueExample 2:...
Delete Node in a Linked List Delete Node in a Linked ListDescriptionWrite a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3...
链表的基本概念以及java实现单链表-循环链表-双向链表 前言线性结构是非常简单且常用的数据结构,而线性表则是一种非常典型的线性结构。线性表定义线性表的数据结构链表 单链表 单链表的定义 单链表的插入和删除 单链表的遍历,清空,判空,获取指定结点 循环链表 循环链表的定义循环链表的插入和删除循环链表的遍历,清空双向链表 双向链表的定义双向链表的插入和删除本节代码传送门,欢迎star:https://github...
Palindrome Linked List Palindrome Linked ListDescriptionGiven a singly linked list, determine if it is a palindrome.Example1:Input: 1->2Output: falseExample2:Input: 1->2->2->1Output:
Contains Duplicate Contains DuplicateDescriptionGiven an array of integers, find if the array contains any duplicates.Your function should return true if any value appears at least twice in the array, and it sho...
Split Linked List in Parts Split Linked List in PartsDescriptionGiven a (singly) linked list with head node root, write a function to split the linked list into k consecutive linked list “parts”.The length of each part ...
深入了解java的装箱与拆箱 1 前言java是面向对象的语言,但是其也包含了8中基本数据类型,这8种数据类型不支持面向对象的编程机制,即不具备对象的特性,可以说是java语言早期设计的一种缺陷,为了解决8种基本数据类型的变量不能当成Object类型变量使用的问题,java提出了包装类(Wrapper class)的概念。本节主要了解:基本类型与包装类型之间的转换什么是装箱?什么是拆箱?装箱和拆箱是如何实现的装...
Intersection of Two Linked Lists Intersection of Two Linked ListsDescriptionWrite a program to find the node at which the intersection of two singly linked lists begins.Example 1:A: a1 → a2 ↘ ...
Remove Linked List Elements Remove Linked List ElementsDescriptionRemove all elements from a linked list of integers that have value val.Example 1:Input: 1->2->6->3->4->5->6, val = 6Output: 1->...
Find Peak Element Find Peak ElementDescriptionA peak element is an element that is greater than its neighbors.Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return its index.The...
Find Right Interval Find Right IntervalDescriptionGiven a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point of the interval...