From 2324420caf7a24fed7feee10bdbb0f5745cbf94b Mon Sep 17 00:00:00 2001 From: yanglbme Date: Wed, 10 Apr 2024 08:52:17 +0800 Subject: [PATCH] feat: update lc problems --- .../README.md | 16 ++++++++-------- .../README.md | 4 ++-- .../README_EN.md | 4 ++-- .../README.md | 2 +- .../README_EN.md | 2 +- .../README.md | 2 +- .../README_EN.md | 2 +- .../README.md | 14 ++++++-------- .../README_EN.md | 6 ++++-- .../README.md | 2 +- .../README_EN.md | 5 +++-- solution/README.md | 10 +++++----- solution/README_EN.md | 10 +++++----- 13 files changed, 40 insertions(+), 39 deletions(-) diff --git a/solution/3000-3099/3082.Find the Sum of the Power of All Subsequences/README.md b/solution/3000-3099/3082.Find the Sum of the Power of All Subsequences/README.md index ead1c284ecbd5..93d1dbbd25e01 100644 --- a/solution/3000-3099/3082.Find the Sum of the Power of All Subsequences/README.md +++ b/solution/3000-3099/3082.Find the Sum of the Power of All Subsequences/README.md @@ -30,11 +30,11 @@

总共有 5 个能量不为 0 的子序列:

所以答案为 2 + 1 + 1 + 1 + 1 = 6 。

@@ -52,9 +52,9 @@

总共有 3 个能量不为 0 的子序列:

所以答案为 2 + 1 + 1 = 4 。

diff --git a/solution/3100-3199/3104.Find Longest Self-Contained Substring/README.md b/solution/3100-3199/3104.Find Longest Self-Contained Substring/README.md index 7ae161769eb82..460b52128452a 100644 --- a/solution/3100-3199/3104.Find Longest Self-Contained Substring/README.md +++ b/solution/3100-3199/3104.Find Longest Self-Contained Substring/README.md @@ -2,7 +2,7 @@ [English Version](/solution/3100-3199/3104.Find%20Longest%20Self-Contained%20Substring/README_EN.md) - + ## 题目描述 @@ -10,7 +10,7 @@

Given a string s, your task is to find the length of the longest self-contained substring of s.

-

A substring t of a string s is considered self-contained if t != s and for every character in t, it doesn't exist in the rest of s.

+

A substring t of a string s is called self-contained if t != s and for every character in t, it doesn't exist in the rest of s.

Return the length of the longest self-contained substring of s if it exists, otherwise, return -1.

diff --git a/solution/3100-3199/3104.Find Longest Self-Contained Substring/README_EN.md b/solution/3100-3199/3104.Find Longest Self-Contained Substring/README_EN.md index 571d4e98e4dcd..5d6d1fbcebee9 100644 --- a/solution/3100-3199/3104.Find Longest Self-Contained Substring/README_EN.md +++ b/solution/3100-3199/3104.Find Longest Self-Contained Substring/README_EN.md @@ -2,13 +2,13 @@ [中文文档](/solution/3100-3199/3104.Find%20Longest%20Self-Contained%20Substring/README.md) - + ## Description

Given a string s, your task is to find the length of the longest self-contained substring of s.

-

A substring t of a string s is considered self-contained if t != s and for every character in t, it doesn't exist in the rest of s.

+

A substring t of a string s is called self-contained if t != s and for every character in t, it doesn't exist in the rest of s.

Return the length of the longest self-contained substring of s if it exists, otherwise, return -1.

diff --git a/solution/3100-3199/3105.Longest Strictly Increasing or Strictly Decreasing Subarray/README.md b/solution/3100-3199/3105.Longest Strictly Increasing or Strictly Decreasing Subarray/README.md index 83eeddbcca9ec..8ffefe58e0308 100644 --- a/solution/3100-3199/3105.Longest Strictly Increasing or Strictly Decreasing Subarray/README.md +++ b/solution/3100-3199/3105.Longest Strictly Increasing or Strictly Decreasing Subarray/README.md @@ -2,7 +2,7 @@ [English Version](/solution/3100-3199/3105.Longest%20Strictly%20Increasing%20or%20Strictly%20Decreasing%20Subarray/README_EN.md) - + ## 题目描述 diff --git a/solution/3100-3199/3105.Longest Strictly Increasing or Strictly Decreasing Subarray/README_EN.md b/solution/3100-3199/3105.Longest Strictly Increasing or Strictly Decreasing Subarray/README_EN.md index ccbe478d9d454..032c7870e5413 100644 --- a/solution/3100-3199/3105.Longest Strictly Increasing or Strictly Decreasing Subarray/README_EN.md +++ b/solution/3100-3199/3105.Longest Strictly Increasing or Strictly Decreasing Subarray/README_EN.md @@ -2,7 +2,7 @@ [中文文档](/solution/3100-3199/3105.Longest%20Strictly%20Increasing%20or%20Strictly%20Decreasing%20Subarray/README.md) - + ## Description diff --git a/solution/3100-3199/3106.Lexicographically Smallest String After Operations With Constraint/README.md b/solution/3100-3199/3106.Lexicographically Smallest String After Operations With Constraint/README.md index 61ade8a2a4374..1cfcefc0adaa4 100644 --- a/solution/3100-3199/3106.Lexicographically Smallest String After Operations With Constraint/README.md +++ b/solution/3100-3199/3106.Lexicographically Smallest String After Operations With Constraint/README.md @@ -2,7 +2,7 @@ [English Version](/solution/3100-3199/3106.Lexicographically%20Smallest%20String%20After%20Operations%20With%20Constraint/README_EN.md) - + ## 题目描述 diff --git a/solution/3100-3199/3106.Lexicographically Smallest String After Operations With Constraint/README_EN.md b/solution/3100-3199/3106.Lexicographically Smallest String After Operations With Constraint/README_EN.md index f7b692b2d4da3..dbeb1c4c1e290 100644 --- a/solution/3100-3199/3106.Lexicographically Smallest String After Operations With Constraint/README_EN.md +++ b/solution/3100-3199/3106.Lexicographically Smallest String After Operations With Constraint/README_EN.md @@ -2,7 +2,7 @@ [中文文档](/solution/3100-3199/3106.Lexicographically%20Smallest%20String%20After%20Operations%20With%20Constraint/README.md) - + ## Description diff --git a/solution/3100-3199/3107.Minimum Operations to Make Median of Array Equal to K/README.md b/solution/3100-3199/3107.Minimum Operations to Make Median of Array Equal to K/README.md index a61515c7658d2..00b69da6f3414 100644 --- a/solution/3100-3199/3107.Minimum Operations to Make Median of Array Equal to K/README.md +++ b/solution/3100-3199/3107.Minimum Operations to Make Median of Array Equal to K/README.md @@ -2,19 +2,17 @@ [English Version](/solution/3100-3199/3107.Minimum%20Operations%20to%20Make%20Median%20of%20Array%20Equal%20to%20K/README_EN.md) - + ## 题目描述 -

给你一个整数数组 nums 和一个 非负 整数 k 。

- -

一次操作中,你可以选择任一下标 i ,然后将 nums[i] 加 1 或者减 1 。

+

给你一个整数数组 nums 和一个 非负 整数 k 。一次操作中,你可以选择任一元素 加 1 或者减 1 。

请你返回将 nums 中位数 变为 k 所需要的 最少 操作次数。

-

一个数组的 中位数 指的是数组按 非递减 顺序排序后最中间的元素。如果数组长度为偶数,我们选择中间两个数的较大值为中位数。

+

一个数组的中位数指的是数组按非递减顺序排序后最中间的元素。如果数组长度为偶数,我们选择中间两个数的较大值为中位数。

 

@@ -25,7 +23,7 @@

输出:2

-

解释:我们将 nums[1] 和 nums[4] 减 1 得到 [2, 4, 6, 8, 4] 。现在数组的中位数等于 k 。所以答案为 2 。

+

解释:我们将 nums[1] 和 nums[4] 减 1 得到 [2, 4, 6, 8, 4] 。现在数组的中位数等于 k 。

示例 2:

@@ -35,7 +33,7 @@

输出:3

-

解释:我们将 nums[1] 增加 1 两次,并且将 nums[2] 增加 1 一次,得到 [2, 7, 7, 8, 5] 。结果数组的中位数等于 k 。所以答案为 3 。

+

解释:我们将 nums[1] 增加 1 两次,并且将 nums[2] 增加 1 一次,得到 [2, 7, 7, 8, 5] 。

示例 3:

@@ -45,7 +43,7 @@

输出:0

-

解释:数组中位数已经等于 k 了,所以不需要进行任何操作。

+

解释:数组中位数已经等于 k 了。

 

diff --git a/solution/3100-3199/3107.Minimum Operations to Make Median of Array Equal to K/README_EN.md b/solution/3100-3199/3107.Minimum Operations to Make Median of Array Equal to K/README_EN.md index ca4e8ddda30ca..c6fb889790d0f 100644 --- a/solution/3100-3199/3107.Minimum Operations to Make Median of Array Equal to K/README_EN.md +++ b/solution/3100-3199/3107.Minimum Operations to Make Median of Array Equal to K/README_EN.md @@ -2,13 +2,15 @@ [中文文档](/solution/3100-3199/3107.Minimum%20Operations%20to%20Make%20Median%20of%20Array%20Equal%20to%20K/README.md) - + ## Description

You are given an integer array nums and a non-negative integer k. In one operation, you can increase or decrease any element by 1.

-

Return the minimum number of operations needed to make the median of nums equal to k.

+

Return the minimum number of operations needed to make the median of nums equal to k.

+ +

The median of an array is defined as the middle element of the array when it is sorted in non-decreasing order. If there are two choices for a median, the larger of the two values is taken.

 

Example 1:

diff --git a/solution/3100-3199/3108.Minimum Cost Walk in Weighted Graph/README.md b/solution/3100-3199/3108.Minimum Cost Walk in Weighted Graph/README.md index 4d596b2dcac86..fe61af8235f32 100644 --- a/solution/3100-3199/3108.Minimum Cost Walk in Weighted Graph/README.md +++ b/solution/3100-3199/3108.Minimum Cost Walk in Weighted Graph/README.md @@ -2,7 +2,7 @@ [English Version](/solution/3100-3199/3108.Minimum%20Cost%20Walk%20in%20Weighted%20Graph/README_EN.md) - + ## 题目描述 diff --git a/solution/3100-3199/3108.Minimum Cost Walk in Weighted Graph/README_EN.md b/solution/3100-3199/3108.Minimum Cost Walk in Weighted Graph/README_EN.md index be8b89cad3d21..526d002f3b08e 100644 --- a/solution/3100-3199/3108.Minimum Cost Walk in Weighted Graph/README_EN.md +++ b/solution/3100-3199/3108.Minimum Cost Walk in Weighted Graph/README_EN.md @@ -2,7 +2,7 @@ [中文文档](/solution/3100-3199/3108.Minimum%20Cost%20Walk%20in%20Weighted%20Graph/README.md) - + ## Description @@ -49,7 +49,7 @@

Constraints:

## Solutions diff --git a/solution/README.md b/solution/README.md index a9d23c834b51e..ddfea8307ed01 100644 --- a/solution/README.md +++ b/solution/README.md @@ -3114,11 +3114,11 @@ | 3101 | [交替子数组计数](/solution/3100-3199/3101.Count%20Alternating%20Subarrays/README.md) | `数组`,`数学` | 中等 | 第 391 场周赛 | | 3102 | [最小化曼哈顿距离](/solution/3100-3199/3102.Minimize%20Manhattan%20Distances/README.md) | `数组`,`数学` | 困难 | 第 391 场周赛 | | 3103 | [查找热门话题标签 II](/solution/3100-3199/3103.Find%20Trending%20Hashtags%20II/README.md) | `数据库` | 困难 | 🔒 | -| 3104 | [Find Longest Self-Contained Substring](/solution/3100-3199/3104.Find%20Longest%20Self-Contained%20Substring/README.md) | | 困难 | 🔒 | -| 3105 | [最长的严格递增或递减子数组](/solution/3100-3199/3105.Longest%20Strictly%20Increasing%20or%20Strictly%20Decreasing%20Subarray/README.md) | | 简单 | 第 392 场周赛 | -| 3106 | [满足距离约束且字典序最小的字符串](/solution/3100-3199/3106.Lexicographically%20Smallest%20String%20After%20Operations%20With%20Constraint/README.md) | | 中等 | 第 392 场周赛 | -| 3107 | [使数组中位数等于 K 的最少操作数](/solution/3100-3199/3107.Minimum%20Operations%20to%20Make%20Median%20of%20Array%20Equal%20to%20K/README.md) | | 中等 | 第 392 场周赛 | -| 3108 | [带权图里旅途的最小代价](/solution/3100-3199/3108.Minimum%20Cost%20Walk%20in%20Weighted%20Graph/README.md) | | 困难 | 第 392 场周赛 | +| 3104 | [Find Longest Self-Contained Substring](/solution/3100-3199/3104.Find%20Longest%20Self-Contained%20Substring/README.md) | `哈希表`,`字符串`,`二分查找`,`前缀和` | 困难 | 🔒 | +| 3105 | [最长的严格递增或递减子数组](/solution/3100-3199/3105.Longest%20Strictly%20Increasing%20or%20Strictly%20Decreasing%20Subarray/README.md) | `数组` | 简单 | 第 392 场周赛 | +| 3106 | [满足距离约束且字典序最小的字符串](/solution/3100-3199/3106.Lexicographically%20Smallest%20String%20After%20Operations%20With%20Constraint/README.md) | `贪心`,`字符串` | 中等 | 第 392 场周赛 | +| 3107 | [使数组中位数等于 K 的最少操作数](/solution/3100-3199/3107.Minimum%20Operations%20to%20Make%20Median%20of%20Array%20Equal%20to%20K/README.md) | `贪心`,`数组`,`排序` | 中等 | 第 392 场周赛 | +| 3108 | [带权图里旅途的最小代价](/solution/3100-3199/3108.Minimum%20Cost%20Walk%20in%20Weighted%20Graph/README.md) | `位运算`,`并查集`,`图`,`数组` | 困难 | 第 392 场周赛 | ## 版权 diff --git a/solution/README_EN.md b/solution/README_EN.md index fb3ad9d289bac..6fb4cb3ff0957 100644 --- a/solution/README_EN.md +++ b/solution/README_EN.md @@ -3112,11 +3112,11 @@ Press Control + F(or Command + F on | 3101 | [Count Alternating Subarrays](/solution/3100-3199/3101.Count%20Alternating%20Subarrays/README_EN.md) | `Array`,`Math` | Medium | Weekly Contest 391 | | 3102 | [Minimize Manhattan Distances](/solution/3100-3199/3102.Minimize%20Manhattan%20Distances/README_EN.md) | `Array`,`Math` | Hard | Weekly Contest 391 | | 3103 | [Find Trending Hashtags II](/solution/3100-3199/3103.Find%20Trending%20Hashtags%20II/README_EN.md) | `Database` | Hard | 🔒 | -| 3104 | [Find Longest Self-Contained Substring](/solution/3100-3199/3104.Find%20Longest%20Self-Contained%20Substring/README_EN.md) | | Hard | 🔒 | -| 3105 | [Longest Strictly Increasing or Strictly Decreasing Subarray](/solution/3100-3199/3105.Longest%20Strictly%20Increasing%20or%20Strictly%20Decreasing%20Subarray/README_EN.md) | | Easy | Weekly Contest 392 | -| 3106 | [Lexicographically Smallest String After Operations With Constraint](/solution/3100-3199/3106.Lexicographically%20Smallest%20String%20After%20Operations%20With%20Constraint/README_EN.md) | | Medium | Weekly Contest 392 | -| 3107 | [Minimum Operations to Make Median of Array Equal to K](/solution/3100-3199/3107.Minimum%20Operations%20to%20Make%20Median%20of%20Array%20Equal%20to%20K/README_EN.md) | | Medium | Weekly Contest 392 | -| 3108 | [Minimum Cost Walk in Weighted Graph](/solution/3100-3199/3108.Minimum%20Cost%20Walk%20in%20Weighted%20Graph/README_EN.md) | | Hard | Weekly Contest 392 | +| 3104 | [Find Longest Self-Contained Substring](/solution/3100-3199/3104.Find%20Longest%20Self-Contained%20Substring/README_EN.md) | `Hash Table`,`String`,`Binary Search`,`Prefix Sum` | Hard | 🔒 | +| 3105 | [Longest Strictly Increasing or Strictly Decreasing Subarray](/solution/3100-3199/3105.Longest%20Strictly%20Increasing%20or%20Strictly%20Decreasing%20Subarray/README_EN.md) | `Array` | Easy | Weekly Contest 392 | +| 3106 | [Lexicographically Smallest String After Operations With Constraint](/solution/3100-3199/3106.Lexicographically%20Smallest%20String%20After%20Operations%20With%20Constraint/README_EN.md) | `Greedy`,`String` | Medium | Weekly Contest 392 | +| 3107 | [Minimum Operations to Make Median of Array Equal to K](/solution/3100-3199/3107.Minimum%20Operations%20to%20Make%20Median%20of%20Array%20Equal%20to%20K/README_EN.md) | `Greedy`,`Array`,`Sorting` | Medium | Weekly Contest 392 | +| 3108 | [Minimum Cost Walk in Weighted Graph](/solution/3100-3199/3108.Minimum%20Cost%20Walk%20in%20Weighted%20Graph/README_EN.md) | `Bit Manipulation`,`Union Find`,`Graph`,`Array` | Hard | Weekly Contest 392 | ## Copyright