diff --git a/solution/2900-2999/2936.Number of Equal Numbers Blocks/README.md b/solution/2900-2999/2936.Number of Equal Numbers Blocks/README.md new file mode 100644 index 0000000000000..7fabdf9a2609a --- /dev/null +++ b/solution/2900-2999/2936.Number of Equal Numbers Blocks/README.md @@ -0,0 +1,106 @@ +# [2936. Number of Equal Numbers Blocks](https://leetcode.cn/problems/number-of-equal-numbers-blocks) + +[English Version](/solution/2900-2999/2936.Number%20of%20Equal%20Numbers%20Blocks/README_EN.md) + +## 题目描述 + + + +

You are given a 0-indexed array of integers, nums. The following property holds for nums:

+ + + +

Since nums is a very large array, you are given an instance of the class BigArray which has the following functions:

+ + + +

Let's partition the array into maximal blocks such that each block contains equal values. Return the number of these blocks.

+ +

Note that if you want to test your solution using a custom test, behavior for tests with nums.length > 10 is undefined.

+ +

 

+

Example 1:

+ +
+Input: nums = [3,3,3,3,3]
+Output: 1
+Explanation: There is only one block here which is the whole array (because all numbers are equal) and that is: [3,3,3,3,3]. So the answer would be 1. 
+
+ +

Example 2:

+ +
+Input: nums = [1,1,1,3,9,9,9,2,10,10]
+Output: 5
+Explanation: There are 5 blocks here:
+Block number 1: [1,1,1,3,9,9,9,2,10,10]
+Block number 2: [1,1,1,3,9,9,9,2,10,10]
+Block number 3: [1,1,1,3,9,9,9,2,10,10]
+Block number 4: [1,1,1,3,9,9,9,2,10,10]
+Block number 5: [1,1,1,3,9,9,9,2,10,10]
+So the answer would be 5.
+ +

Example 3:

+ +
+Input: nums = [1,2,3,4,5,6,7]
+Output: 7
+Explanation: Since all numbers are distinct, there are 7 blocks here and each element representing one block. So the answer would be 7. 
+
+ +

 

+

Constraints:

+ + + +## 解法 + + + + + +### **Python3** + + + +```python + +``` + +### **Java** + + + +```java + +``` + +### **C++** + +```cpp + +``` + +### **Go** + +```go + +``` + +### **...** + +``` + +``` + + diff --git a/solution/2900-2999/2936.Number of Equal Numbers Blocks/README_EN.md b/solution/2900-2999/2936.Number of Equal Numbers Blocks/README_EN.md new file mode 100644 index 0000000000000..b7cdf04b440ce --- /dev/null +++ b/solution/2900-2999/2936.Number of Equal Numbers Blocks/README_EN.md @@ -0,0 +1,98 @@ +# [2936. Number of Equal Numbers Blocks](https://leetcode.com/problems/number-of-equal-numbers-blocks) + +[中文文档](/solution/2900-2999/2936.Number%20of%20Equal%20Numbers%20Blocks/README.md) + +## Description + +

You are given a 0-indexed array of integers, nums. The following property holds for nums:

+ + + +

Since nums is a very large array, you are given an instance of the class BigArray which has the following functions:

+ + + +

Let's partition the array into maximal blocks such that each block contains equal values. Return the number of these blocks.

+ +

Note that if you want to test your solution using a custom test, behavior for tests with nums.length > 10 is undefined.

+ +

 

+

Example 1:

+ +
+Input: nums = [3,3,3,3,3]
+Output: 1
+Explanation: There is only one block here which is the whole array (because all numbers are equal) and that is: [3,3,3,3,3]. So the answer would be 1. 
+
+ +

Example 2:

+ +
+Input: nums = [1,1,1,3,9,9,9,2,10,10]
+Output: 5
+Explanation: There are 5 blocks here:
+Block number 1: [1,1,1,3,9,9,9,2,10,10]
+Block number 2: [1,1,1,3,9,9,9,2,10,10]
+Block number 3: [1,1,1,3,9,9,9,2,10,10]
+Block number 4: [1,1,1,3,9,9,9,2,10,10]
+Block number 5: [1,1,1,3,9,9,9,2,10,10]
+So the answer would be 5.
+ +

Example 3:

+ +
+Input: nums = [1,2,3,4,5,6,7]
+Output: 7
+Explanation: Since all numbers are distinct, there are 7 blocks here and each element representing one block. So the answer would be 7. 
+
+ +

 

+

Constraints:

+ + + +## Solutions + + + +### **Python3** + +```python + +``` + +### **Java** + +```java + +``` + +### **C++** + +```cpp + +``` + +### **Go** + +```go + +``` + +### **...** + +``` + +``` + + diff --git a/solution/README.md b/solution/README.md index 9fc265c1346e0..fd7aaf545d8e3 100644 --- a/solution/README.md +++ b/solution/README.md @@ -2946,6 +2946,7 @@ | 2933 | [高访问员工](/solution/2900-2999/2933.High-Access%20Employees/README.md) | | 中等 | 第 371 场周赛 | | 2934 | [最大化数组末位元素的最少操作次数](/solution/2900-2999/2934.Minimum%20Operations%20to%20Maximize%20Last%20Elements%20in%20Arrays/README.md) | | 中等 | 第 371 场周赛 | | 2935 | [找出强数对的最大异或值 II](/solution/2900-2999/2935.Maximum%20Strong%20Pair%20XOR%20II/README.md) | | 困难 | 第 371 场周赛 | +| 2936 | [Number of Equal Numbers Blocks](/solution/2900-2999/2936.Number%20of%20Equal%20Numbers%20Blocks/README.md) | | 中等 | 🔒 | ## 版权 diff --git a/solution/README_EN.md b/solution/README_EN.md index 2092552853805..c87aa714c53aa 100644 --- a/solution/README_EN.md +++ b/solution/README_EN.md @@ -2944,6 +2944,7 @@ Press Control + F(or Command + F on | 2933 | [High-Access Employees](/solution/2900-2999/2933.High-Access%20Employees/README_EN.md) | | Medium | Weekly Contest 371 | | 2934 | [Minimum Operations to Maximize Last Elements in Arrays](/solution/2900-2999/2934.Minimum%20Operations%20to%20Maximize%20Last%20Elements%20in%20Arrays/README_EN.md) | | Medium | Weekly Contest 371 | | 2935 | [Maximum Strong Pair XOR II](/solution/2900-2999/2935.Maximum%20Strong%20Pair%20XOR%20II/README_EN.md) | | Hard | Weekly Contest 371 | +| 2936 | [Number of Equal Numbers Blocks](/solution/2900-2999/2936.Number%20of%20Equal%20Numbers%20Blocks/README_EN.md) | | Medium | 🔒 | ## Copyright diff --git a/solution/summary.md b/solution/summary.md index 4d6ec6924d8fe..bee681dbb53ce 100644 --- a/solution/summary.md +++ b/solution/summary.md @@ -2993,3 +2993,4 @@ - [2933.高访问员工](/solution/2900-2999/2933.High-Access%20Employees/README.md) - [2934.最大化数组末位元素的最少操作次数](/solution/2900-2999/2934.Minimum%20Operations%20to%20Maximize%20Last%20Elements%20in%20Arrays/README.md) - [2935.找出强数对的最大异或值 II](/solution/2900-2999/2935.Maximum%20Strong%20Pair%20XOR%20II/README.md) + - [2936.Number of Equal Numbers Blocks](/solution/2900-2999/2936.Number%20of%20Equal%20Numbers%20Blocks/README.md) diff --git a/solution/summary_en.md b/solution/summary_en.md index e737312a155df..7578dc7c93756 100644 --- a/solution/summary_en.md +++ b/solution/summary_en.md @@ -2993,3 +2993,4 @@ - [2933.High-Access Employees](/solution/2900-2999/2933.High-Access%20Employees/README_EN.md) - [2934.Minimum Operations to Maximize Last Elements in Arrays](/solution/2900-2999/2934.Minimum%20Operations%20to%20Maximize%20Last%20Elements%20in%20Arrays/README_EN.md) - [2935.Maximum Strong Pair XOR II](/solution/2900-2999/2935.Maximum%20Strong%20Pair%20XOR%20II/README_EN.md) + - [2936.Number of Equal Numbers Blocks](/solution/2900-2999/2936.Number%20of%20Equal%20Numbers%20Blocks/README_EN.md)