队列leetcode day9 day

消息队列

简介: 在C#中,消息队列是一种用于在应用程序之间异步传递消息的通信机制。它通常被用于异步通信,允许发送者和接收者在不需要立即相互作用的情况下进行消息交换,可以用来解耦应用程序的各个组件,实现分布式系统之间的通信,并提供可靠性和可扩展性。 消息队列系统通常包括以下核心组件: 消息:消息是要传输的数据 ......
队列 消息

day15 模块基础 continued

2023年12月6日 周三 13:16:00循环导入:两个文件f1 f2互相import而出现的问题 代码自上而下运行 可能有时候需要导入的名字在f1里面还未生成 f2就调用这个名字 就会报错解决方案:①先生成名字 再import②把import放入函数体内 因为在定义函数的时候 只检测语法 不运行 ......
continued 模块 基础 day 15

day 01 计算机基础和环境搭建

1.计算机基础 1.1 基本概念 计算机的组成 计算机是由多个硬件组合而成,常见的硬件有:CPU、硬盘、内存、网卡、显示器、机箱、电源... 操作系统 用于协调计算机的各个硬件,让硬件之间协作工作,以完成某个目标 - Windows - Linux - Mac 软件 在安装上操作系统之后,我们会在自 ......
环境 计算机 基础 day 01

[LeetCode] 498. Diagonal Traverse 对角线遍历

题目 Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order. 思考 最初在纸上写写画画试了很多想法,但都没能解决,真的。。太弱了T T。 后来在YT上看了个印度老 ......
对角线 对角 LeetCode Diagonal Traverse

[LeetCode Hot 100] LeetCode73. 矩阵置零

题目描述 思路一:开辟两个数组,时间复杂度O(m + n) 开辟两个数组用来记录哪些行、哪些列需要置为零。 这样时间复杂度为O(m + n)。 思路二: 原地算法:不适用额外空间或者说常数级空间来实现算法。 类似于使用set保存每行每列是否需要置零, 方法一:对应思路一 class Solution ......
LeetCode 矩阵 Hot 100 73

leetcode-1662-easy

Check If Two String Arrays are Equivalent 思路一:把第一个数组入队列,然后遍历比较第二个数组 public boolean arrayStringsAreEqual(String[] word1, String[] word2) { Deque<Charac ......
leetcode 1662 easy

leetcode-1732-easy

Find the Highest Altitude 思路一:直接遍历 public int largestAltitude(int[] gain) { int val = 0; int max = val; for (int i : gain) { val += i; max = Math.max( ......
leetcode 1732 easy

leetcode-1646-easy

Get Maximum in Generated Array You are given an integer n. A 0-indexed integer array nums of length n + 1 is generated in the following way: nums[0] = ......
leetcode 1646 easy

leetcode-2169-easy

Count Operations to Obtain Zero You are given two non-negative integers num1 and num2. In one operation, if num1 >= num2, you must subtract num2 from ......
leetcode 2169 easy

leetcode-2180-easy

Count Integers With Even Digit Sum Given a positive integer num, return the number of positive integers less than or equal to num whose digit sums are ......
leetcode 2180 easy

leetcode-1455-easy

Check If a Word Occurs As a Prefix of Any Word in a Sentence Given a sentence that consists of some words separated by a single space, and a searchWor ......
leetcode 1455 easy

leetcode-1464-easy

Maximum Product of Two Elements in an Array Given the array of integers nums, you will choose two different indices i and j of that array. Return the ......
leetcode 1464 easy

leetcode-1512-easy

Number of Good Pairs Given an array of integers nums, return the number of good pairs. A pair (i, j) is called good if nums[i] == nums[j] and i < j. E ......
leetcode 1512 easy

leetcode-1550-easy

Three Consecutive Odds Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false. Examp ......
leetcode 1550 easy

leetcode-1572-easy

Matrix Diagonal Sum Given a square matrix mat, return the sum of the matrix diagonals. Only include the sum of all the elements on the primary diagona ......
leetcode 1572 easy

[LeetCode] 1688. Count of Matches in Tournament

You are given an integer n, the number of teams in a tournament that has strange rules: If the current number of teams is even, each team gets paired ......
Tournament LeetCode Matches Count 1688

Leetcode 80. 删除有序数组中的重复项 II

被前面类似的题禁锢了思路,自己写的双指针,感觉题解很巧妙,记录一下。这个解法不用记录cnt。 通用解法 为了让解法更具有一般性,我们将原问题的「保留 2 位」修改为「保留 k 位」。 对于此类问题,我们应该进行如下考虑: 由于是保留 k 个相同数字,对于前 k 个数字,我们可以直接保留 对于后面的任 ......
数组 Leetcode 80 II

Leetcode刷题day6-哈希表.双指针.三~四数求和.

454.四数相加Ⅱ 454. 四数相加 II - 力扣(LeetCode) 给你四个整数数组 nums1、nums2、nums3 和 nums4 ,数组长度都是 n ,请你计算有多少个元组 (i, j, k, l) 能满足: 0 <= i, j, k, l < n nums1[i] + nums2[ ......
指针 Leetcode day6 day

[LeetCode Hot 100] LeetCode19. 删除链表的倒数第N个结点

题目描述 思路一:采用两次遍历 第一遍遍历先获取链表的长度length 第二次从dummy节点开始走length - n步 然后将该节点指向下下个节点 思路二:采用一次遍历 设置虚拟节点dummyHead指向head 设定双指针p和q,初始都指向虚拟节点dummyHead 移动q,直到p与q之间相隔 ......
LeetCode 结点 Hot 100 19

Day20 Java流程控制02:scanner进阶使用

Java流程控制02:scanner进阶使用 1.判断是否是整数/小数: package com.baixiaofan.scanner; import java.util.Scanner; public class Demo04 { public static void main(String[] ......
流程 scanner Java Day 20

单调栈与单调队列算法总结

单调栈 知识概览 单调栈最常见的应用是找到每一个数离它最近的且比它小的数。 单调栈考虑的方式和双指针类似,都是先想一下暴力做法是什么,然后再挖掘一些性质如单调性,最终可以把目光集中在比较少的状态中,从而达到降低时间复杂度的作用,都是算法优化的一种手段。 对于的情况,更有可能是答案,因此将删掉。最终, ......
队列 算法

day15 函数复习和模块基础

蒙特卡洛仿真 2023-12-05 19:28:40函数复习def func(*args,**kwargs): pass #func可以接受所有的参数*形参:接受多余的位置实参 以元组的形式存储**形参:接受多余的关键字参数 以字典的形式存储 函数对象的作用:①引用 f1=func②作为函数的返回值 ......
函数 模块 基础 day 15

[LeetCode Hot 100] LeetCode21. 合并两个有序链表

题目描述 思路:新建dummy去"穿针引线" 新建一个dummy节点去"穿针引线" 注意最后返回的是dummy.next 方法一: /** * Definition for singly-linked list. * public class ListNode { * int val; * List ......
LeetCode 两个 Hot 100 21

day09

1.今日内容介绍 今日内容: 1.字符编码(******) 2.文件处理的高级部分 (1) 文件处理的其他方法 (2) 控制文件指针移动 (3) 文件修改的两种方式 3.函数的基本使用 函数名 参数 函数体代码 函数的返回值 2.字符编码储备知识 文本编辑器读取python文件内容也经历了三个步骤 ......
day 09

day10

1.今日内容 1.函数介绍 什么是函数 为何要用 如何用函数:先定义,后调用 函数 》工厂 函数名 地址 参数 原材料 函数体代码 工厂的流水线 返回值 工厂的产品 2.函数的返回值 3.函数的参数 2.函数的基本使用 ''' 1、什么是函数 函数就是盛放代码的容器,把实现某一功能的一组代码丢到一个 ......
day 10

[LeetCode Hot 100] LeetCode234. 回文链表

题目描述 思路1:将值复制到数组中然后使用双指针 计算链表的长度 创建等长的数组 将链表中的数依次放入数组中 使用左右指针判断链表是否是回文链表 时间复杂度:O(n) 空间复杂度:O(n) 思路2:快慢指针+反转链表 用快慢指针,快指针走两步,慢指针走一步,快指针遇到终止位置时,慢指针就在链表中间位 ......
LeetCode 回文 Hot 100 234

[LeetCode Hot 100] LeetCode206. 反转链表

题目描述 思路:双指针算法 方法一: /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) ......
LeetCode Hot 100 206

[LeetCode Hot 100] LeetCode49. 字母异位词

题目描述 思路:哈希表 对字符串排序,如果是异位词,排序后就变成一样的了。 方法一: class Solution { public List<List<String>> groupAnagrams(String[] strs) { Map<String, List<String>> map = n ......
LeetCode 字母 Hot 100 49

[LeetCode Hot 100] LeetCode141. 环形链表

题目描述 思路:快慢指针 slow指针:每次移动一个节点 fast指针:每次移动两个节点 如果链表中存在环,fast指针最终会在某一时刻追上slow指针,这是由于移动速度快的fast指针会在某个时刻绕圈并追上速度慢的slow指针 条件 fast != null && fast.next != nul ......
LeetCode 环形 Hot 100 141

JavaWeb - Day02 - JS、Vue

01. JS-介绍 什么是JavaScript? JavaScript(简称:JS) 是一门跨平台、面向对象的脚本语言。是用来控制网页行为的,它能使网页可交互。 JavaScript 和 Java 是完全不同的语言,不论是概念还是设计。但是基础语法类似。 JavaScript 在 1995 年由 B ......
JavaWeb Day Vue 02