leetcode75专题

【leetcode75】Intersection of Two Arrays(数组的交集)

题目描述: 给定两个数组求他们的公共部分,输出形式是数组,相同的元素只是输出一次 例如: nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. 原文描述: Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1,

java数据结构与算法刷题-----LeetCode75. 颜色分类

java数据结构与算法刷题目录(剑指Offer、LeetCode、ACM)-----主目录-----持续更新(进不去说明我没写完):https://blog.csdn.net/grd_java/article/details/123063846 文章目录 1. 双指针两次遍历2. 三指针 1. 双指针两次遍历 解题思路:时间复杂度O( n n n),空间复杂度O(

LeetCode75| 单调栈

目录 739 每日温度 901 股票价格跨度 739 每日温度 求后面第一个比他大的元素的位置,单调栈需要递增 求后面第一个比他小的元素的位置,单调栈需要递减 本题栈头到栈底的顺序应该从小到大 class Solution {public:vector<int> dailyTemperatures(vector<int>& temperatures) {stack<int

LeetCode75| 二叉搜索树

目录 700 二叉搜索树中的搜索 迭代  递归 450 删除二叉搜索树中的节点 700 二叉搜索树中的搜索 注意二叉搜索树的性质即可  迭代  class Solution {public:TreeNode* searchBST(TreeNode* root, int val) {while(root != NULL){if(root->val < val)root

LeetCode75| 区间集合

目录 435 无重叠区间 452 用最少的箭引爆气球 435 无重叠区间 class Solution {public:static bool cmp(vector<int>&a,vector<int>&b){return a[0] < b[0];}int eraseOverlapIntervals(vector<vector<int>>& intervals) {int res

LeetCode75——Day31

文章目录 一、题目二、题解 一、题目 206. Reverse Linked List Given the head of a singly linked list, reverse the list, and return the reversed list. Example 1: Input: head = [1,2,3,4,5] Output: [5,4,3,2,1

LeetCode75——Day31

文章目录 一、题目二、题解 一、题目 206. Reverse Linked List Given the head of a singly linked list, reverse the list, and return the reversed list. Example 1: Input: head = [1,2,3,4,5] Output: [5,4,3,2,1

LeetCode75——Day30

文章目录 一、题目二、题解 一、题目 328. Odd Even Linked List Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the re

LeetCode75——Day29

文章目录 一、题目二、题解 一、题目 2095. Delete the Middle Node of a Linked List You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list. The middl

LeetCode75——Day28

文章目录 一、题目二、题解 一、题目 649. Dota2 Senate In the world of Dota2, there are two parties: the Radiant and the Dire. The Dota2 senate consists of senators coming from two parties. Now the Senate w

LeetCode75——Day27

文章目录 一、题目二、题解 一、题目 933. Number of Recent Calls You have a RecentCounter class which counts the number of recent requests within a certain time frame. Implement the RecentCounter class: Re

LeetCode75——Day26

文章目录 一、题目二、题解 一、题目 394. Decode String Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is be

LeetCode75——Day25

文章目录 一、题目二、题解 一、题目 735. Asteroid Collision We are given an array asteroids of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the s

LeetCode75——Day22

文章目录 一、题目二、题解 一、题目 1657. Determine if Two Strings Are Close Two strings are considered close if you can attain one from the other using the following operations: Operation 1: Swap any two

LeetCode75——Day21

文章目录 一、题目二、题解 一、题目 1207. Unique Number of Occurrences Given an array of integers arr, return true if the number of occurrences of each value in the array is unique or false otherwise. Exam

LeetCode75——Day20

文章目录 一、题目二、题解 一、题目 2215. Find the Difference of Two Arrays Given two 0-indexed integer arrays nums1 and nums2, return a list answer of size 2 where: answer[0] is a list of all distinct int

LeetCode75——Day19

文章目录 一、题目二、题解 一、题目 724. Find Pivot Index Given an array of integers nums, calculate the pivot index of this array. The pivot index is the index where the sum of all the numbers strictly to

LeetCode75——Day16

文章目录 一、题目二、题解 一、题目 1004. Max Consecutive Ones III Given a binary array nums and an integer k, return the maximum number of consecutive 1’s in the array if you can flip at most k 0’s. Examp

LeetCode75——Day15

文章目录 一、题目二、题解 一、题目 1456. Maximum Number of Vowels in a Substring of Given Length Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with len

LeetCode75——Day13

文章目录 一、题目二、题解 一、题目 1679. Max Number of K-Sum Pairs You are given an integer array nums and an integer k. In one operation, you can pick two numbers from the array whose sum equals k and re

LeetCode75——Day12

文章目录 一、题目二、题解 一、题目 11. Container With Most Water You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) a

LeetCode75——Day11

文章目录 一、题目二、题解 一、题目 392. Is Subsequence Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string that is formed from

LeetCode75——Day10

文章目录 一、题目二、题解 一、题目 283. Move Zeroes Given an integer array nums, move all 0’s to the end of it while maintaining the relative order of the non-zero elements. Note that you must do this in-

【LeetCode75】第七十四题 每日温度

目录 题目: 示例: 分析: 代码: 题目: 示例: 分析: 题目给我们一个数组,表示每天的温度,要我们返回一个同样长度的数组,答案里装着当前气温的下一个更高气温的距离天数。也就是找到数组中这个数的下一个更大的数,答案填入他们的距离。 那么找到下一个更大或者是更小的值这类题,我们可以使用单调栈来解决。 单调栈顾名思义,是一个栈,不过我们需要维持栈内是单调有序的。

【LeetCode75】第七十三题 用最少数量的箭引爆气球

目录 题目: 示例: 分析: 代码: 题目: 示例: 分析: 本题和上一题基本一样,上一题是要我们尽量让区间不重叠,而本题是要我们尽量让区间重叠。 所以我们的做法和上一题基本一致,只不过由于我们要让尽可能多的区间重叠才可以用最少的箭来引爆所有气球。 因此我们一样是对区间进行排序,按照 左端从小到大的顺序。 接着是拿一个变量去接收最小的右端。 不过右端的更新情

LeetCode75——Day5

文章目录 一、题目二、题解 一、题目 345. Reverse Vowels of a String Given a string s, reverse only all the vowels in the string and return it. The vowels are ‘a’, ‘e’, ‘i’, ‘o’, and ‘u’, and they can appea