leetcode 110

【leetcode】【83】【删除排序链表中的重复元素】

# c++ ## 第一个方法 ### 代码 ```c++ #include #include #include #include // Definition for singly-linked list. struct ListNode { int val; ListNode* next; List ......
leetcode 元素

【leetcode】【21】【合并两个有序链表】

# c++ ## 第一个方法 ### 代码 ```c++ /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nul ......
leetcode 两个

https://leetcode.cn/ 第9题 判断回文数

# 回文数 121 是; 123 不是 #定义一个函数 判断是否是回文数 def get_Hui(num): #将整数num转字符串 str_num = str(num) str_num_change = str_num[::-1] num2 = int(str_num_change) #判断整数n ......
回文 leetcode https cn

leetcode ListNode类--Java

public class ListNode { public int val; public ListNode next; public ListNode() {} public ListNode(int val) { this.val = val; } public ListNode(int va ......
leetcode ListNode Java

leetcode TreeNode类 --java

public class TreeNode { int val; TreeNode left; TreeNode right; public TreeNode() { } public TreeNode(int val) { this.val = val; } public TreeNode(int ......
leetcode TreeNode java

leetcode动态规划-

什么是动态规划 动态规划的定义和特点 动态规划的基本思想和步骤 动态规划的分类和常见问题 线性动态规划 最长公共子序列 最长递增子序列 最大子数组和 区间动态规划 矩阵链乘法 括号化问题 背包动态规划 0-1背包问题 完全背包问题 多重背包问题 状态压缩动态规划 旅行商问题 汉密尔顿回路问题 动态规 ......
leetcode 动态

二叉树-前序遍历-leetcode222

给你一棵 完全二叉树 的根节点 root ,求出该树的节点个数。 完全二叉树 的定义如下:在完全二叉树中,除了最底层节点可能没填满外,其余每层节点数都达到最大值,并且最下面一层的节点都集中在该层最左边的若干位置。若最底层为第 h 层,则该层包含 1~ 2h 个节点。 示例 1: 输入:root = ......
leetcode 222

leetcode动态规划题目总结

ref :https://leetcode.cn/circle/article/2Xxlw3/ 这是一篇我在leetcode.com上撰写的文章Dynamic Programming Summary,就不翻回中文了,直接copy过来了。 Hello everyone, I am a Chinese ......
leetcode 题目 动态

动态规划leetcode 清单

不同的二叉搜索树 (卡特兰数) N 天后的牢房 骑士拨号器 最大为 N 的数字组合 鸡蛋掉落 石子游戏 新21点 分汤 有效的井字游戏 统计不同回文子字符串 编辑距离 买卖股票的最佳时机含手续费 爬楼梯 奇怪的打印机 不同路径 II 不同路径 出界的路径数 二叉树的直径 最大子序和 优美的排列 零钱 ......
清单 leetcode 动态

[LeetCode] 1493. Longest Subarray of 1's After Deleting One Element

Given a binary array nums, you should delete one element from it. Return the size of the longest non-empty subarray containing only 1's in the resulti ......
LeetCode Deleting Subarray Element Longest

动态规划-背包问题-完全背包问题:leetcode 377. 组合总和 Ⅳ

1. 题目 读题 给你一个由 不同 整数组成的数组 nums ,和一个目标整数 target 。请你从 nums 中找出并返回总和为 target 的元素组合的个数。 题目数据保证答案符合 32 位整数范围。 示例 1: 输入:nums = [1,2,3], target = 4输出:7解释:所有可 ......
背包 问题 总和 leetcode 动态

7-010-(LeetCode- 518) 零钱兑换II

1. 题目 读题 518. 零钱兑换 II给你一个整数数组 coins 表示不同面额的硬币,另给一个整数 amount 表示总金额。 请你计算并返回可以凑成总金额的硬币组合数。如果任何硬币组合都无法凑出总金额,返回 0 。 假设每一种面额的硬币有无限个。 题目数据保证结果符合 32 位带符号整数。 ......
零钱 LeetCode 010 518

LeetCode C++:HashTable篇

1、Two Sum Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume tha ......
HashTable LeetCode

leetcode 21. 合并两个有序链表

## 直接合并即可 这道题是简单题,直接合并即可 /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int ......
leetcode 两个 21

[LeetCode] 1071. Greatest Common Divisor of Strings

For two strings s and t, we say "t divides s" if and only if s = t + ... + t (i.e., t is concatenated with itself one or more times). Given two string ......
LeetCode Greatest Divisor Strings Common

[LeetCode] 1186. Maximum Subarray Sum with One Deletion

Given an array of integers, return the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion. In other words, y ......
LeetCode Deletion Subarray Maximum 1186

[LeetCode] 2462. Total Cost to Hire K Workers

You are given a 0-indexed integer array costs where costs[i] is the cost of hiring the ith worker. You are also given two integers k and candidates. W ......
LeetCode Workers Total 2462 Cost

LeetCode —— 滑动窗口

904. 水果成篮 用一个 Map 记录当前窗口的情况: key - 水果种类数 value - 这个水果种类在当前滑动窗口里出现的次数 维持一个 left 指针到 right 指针的滑动窗口 每次 right 右移一位,将新加入窗口的 fruits[right] 这个种类放到 map 里,并将该种 ......
LeetCode

[LeetCode] 2485. Find the Pivot Integer

Given a positive integer n, find the pivot integer x such that: The sum of all elements between 1 and x inclusively equals the sum of all elements bet ......
LeetCode Integer Pivot 2485 Find

LeetCode 128. 最长连续序列

* 为什么这题我都不会,脑袋有点累,状态真差 ``` class Solution { public: int longestConsecutive(vector& nums) { unordered_set s(nums.begin(),nums.end());//记录数字是否出现过 int re ......
序列 LeetCode 128

leetcode-前缀和数组&差分数组

前缀和数组: 前缀和技巧适用于快速、频繁地计算一个索引区间内的元素之和。(仅仅适用于原数组不变的情况,如果原数组经常修改,则需要考虑差分数组。) 看两道例题就清楚了: 1. 303. 区域和检索 - 数组不可变 - 力扣(LeetCode) 由于要频繁计算某个区间内的元素之和,暴力解法复杂度太大,显 ......
数组 前缀 leetcode amp

LeetCode 周赛 351(2023/06/25)T2 有点意思

> **本文已收录到 [AndroidFamily](https://github.com/pengxurui/AndroidFamily),技术和职场问题,请关注公众号 [彭旭锐] 和 [BaguTree Pro] 知识星球提问。** - 往期回顾:[LeetCode 单周赛第 348 场 · 数 ......
LeetCode 意思 2023 351 06

LeetCode 双周赛 107(2023/06/24)滑动窗口与离散化

> **本文已收录到 [AndroidFamily](https://github.com/pengxurui/AndroidFamily),技术和职场问题,请关注公众号 [彭旭锐] 和 [BaguTree Pro] 知识星球提问。** - 往期回顾:[LeetCode 单周赛第 348 场 · 数 ......
LeetCode 2023 107 06 24

【Leetcode每日一题】判定是否互为字符重排

题目 思路 思路比较简单,作两个长度为26的数组,用来存储对应序列字母的个数。遍历完成后对比两个数组,根据是否存在相同序列位置字母个数不一样的情况来确定两个字符串是否都是由相同的字母构成的。 值得一提的是在一开始我忽略了“字母个数必须相同”这一条件。 代码 impl Solution { pub f ......
字符 Leetcode

二叉树-快排-leetcode912

给你一个整数数组 nums,请你将该数组升序排列。 示例 1: 输入:nums = [5,2,3,1] 输出:[1,2,3,5] 示例 2: 输入:nums = [5,1,1,2,0,0] 输出:[0,0,1,1,2,5] 提示: 1 = hi) { return; } // 对 nums[lo.. ......
leetcode 912

[Leetcode] 0026. 删除有序数组中的重复项

# [26. 删除有序数组中的重复项](https://leetcode.cn/problems/remove-duplicates-from-sorted-array) 点击上方,跳转至Leetcode ## 题目描述 给你一个 升序排列 的数组 nums ,请你 原地 删除重复出现的元素,使每个 ......
数组 Leetcode 0026

[Leetcode] 0026.删除有序数组中的重复项

# [26. 删除有序数组中的重复项](https://leetcode.cn/problems/remove-duplicates-from-sorted-array) [English Version](/solution/0000-0099/0026.Remove%20Duplicates%2 ......
数组 Leetcode 0026

[Leetcode] 0021. 合并两个有序链表

# [21. 合并两个有序链表](https://leetcode.cn/problems/merge-two-sorted-lists) 点击上方,跳转至Leetcode ## 题目描述 将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 示例 1: ......
Leetcode 两个 0021

【LeetCode摩尔投票】有趣的简单题:数组中出现次数超过一半的数字

### 数组中出现次数超过一半的数字 https://leetcode.cn/problems/shu-zu-zhong-chu-xian-ci-shu-chao-guo-yi-ban-de-shu-zi-lcof/ 数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字。 你可以假设数组是非 ......
数组 LeetCode 次数 数字

[leetcode]114. 二叉树展开为链表

总结:怎样写递归函数?关键是把递归函数的功能定义清楚,并在递归函数体中使用自身来做事,此时不要关注递归函数执行的细节。也就是写高层级代码的时候不要关注低层级的事情,这就叫抽象。关注也没有用,想不清楚的。 1 class Solution { 2 public void flatten(TreeNod ......
leetcode 114