diff --git "a/lcp/LCP 03. \346\234\272\345\231\250\344\272\272\345\244\247\345\206\222\351\231\251/README.md" "b/lcp/LCP 03. \346\234\272\345\231\250\344\272\272\345\244\247\345\206\222\351\231\251/README.md"
index da59c19bea817..4a10c79e9ade4 100644
--- "a/lcp/LCP 03. \346\234\272\345\231\250\344\272\272\345\244\247\345\206\222\351\231\251/README.md"
+++ "b/lcp/LCP 03. \346\234\272\345\231\250\344\272\272\345\244\247\345\206\222\351\231\251/README.md"
@@ -247,7 +247,7 @@ class Solution {
var visited: Set<[Int]> = []
var i = 0, j = 0
visited.insert([i, j])
-
+
for c in command {
if c == "U" {
j += 1
@@ -256,16 +256,16 @@ class Solution {
}
visited.insert([i, j])
}
-
+
func canReach(_ targetX: Int, _ targetY: Int) -> Bool {
let k = min(targetX / i, targetY / j)
return visited.contains([targetX - k * i, targetY - k * j])
}
-
+
if !canReach(x, y) {
return false
}
-
+
for obstacle in obstacles {
let obstacleX = obstacle[0]
let obstacleY = obstacle[1]
@@ -276,7 +276,7 @@ class Solution {
return false
}
}
-
+
return true
}
}
diff --git a/solution/0400-0499/0410.Split Array Largest Sum/README.md b/solution/0400-0499/0410.Split Array Largest Sum/README.md
index ddfe53ae1df6d..addd3804153c2 100644
--- a/solution/0400-0499/0410.Split Array Largest Sum/README.md
+++ b/solution/0400-0499/0410.Split Array Largest Sum/README.md
@@ -20,9 +20,11 @@ tags:
-
给定一个非负整数数组 nums
和一个整数 k
,你需要将这个数组分成 k
个非空的连续子数组。
+给定一个非负整数数组 nums
和一个整数 k
,你需要将这个数组分成 k
个非空的连续子数组,使得这 k
个子数组各自和的最大值 最小。
-设计一个算法使得这 k
个子数组各自和的最大值最小。
+返回分割后最小的和的最大值。
+
+子数组 是数组中连续的部份。
diff --git a/solution/0600-0699/0636.Exclusive Time of Functions/README.md b/solution/0600-0699/0636.Exclusive Time of Functions/README.md
index cf2ae27ccdb7f..9dc839b951335 100644
--- a/solution/0600-0699/0636.Exclusive Time of Functions/README.md
+++ b/solution/0600-0699/0636.Exclusive Time of Functions/README.md
@@ -34,10 +34,10 @@ tags:
输入:n = 2, logs = ["0:start:0","1:start:2","1:end:5","0:end:6"]
输出:[3,4]
解释:
-函数 0 在时间戳 0 的起始开始执行,执行 2 个单位时间,于时间戳 1 的末尾结束执行。
-函数 1 在时间戳 2 的起始开始执行,执行 4 个单位时间,于时间戳 5 的末尾结束执行。
-函数 0 在时间戳 6 的开始恢复执行,执行 1 个单位时间。
-所以函数 0 总共执行 2 + 1 = 3 个单位时间,函数 1 总共执行 4 个单位时间。
+函数 0 在时间戳 0 的起始开始执行,执行 2 个单位时间,于时间戳 1 的末尾结束执行。
+函数 1 在时间戳 2 的起始开始执行,执行 4 个单位时间,于时间戳 5 的末尾结束执行。
+函数 0 在时间戳 6 的开始恢复执行,执行 1 个单位时间。
+所以函数 0 总共执行 2 + 1 = 3 个单位时间,函数 1 总共执行 4 个单位时间。
示例 2:
diff --git a/solution/2200-2299/2265.Count Nodes Equal to Average of Subtree/README_EN.md b/solution/2200-2299/2265.Count Nodes Equal to Average of Subtree/README_EN.md
index cb2236a60519a..ed387dd7185c1 100644
--- a/solution/2200-2299/2265.Count Nodes Equal to Average of Subtree/README_EN.md
+++ b/solution/2200-2299/2265.Count Nodes Equal to Average of Subtree/README_EN.md
@@ -35,7 +35,7 @@ tags:
Input: root = [4,8,5,0,1,null,6]
Output: 5
-Explanation:
+Explanation:
For the node with value 4: The average of its subtree is (4 + 8 + 5 + 0 + 1 + 6) / 6 = 24 / 6 = 4.
For the node with value 5: The average of its subtree is (5 + 6) / 2 = 11 / 2 = 5.
For the node with value 0: The average of its subtree is 0 / 1 = 0.
diff --git a/solution/2200-2299/2270.Number of Ways to Split Array/README_EN.md b/solution/2200-2299/2270.Number of Ways to Split Array/README_EN.md
index 0ce7fb9cea2d5..34c6224b03e69 100644
--- a/solution/2200-2299/2270.Number of Ways to Split Array/README_EN.md
+++ b/solution/2200-2299/2270.Number of Ways to Split Array/README_EN.md
@@ -36,7 +36,7 @@ tags:
Input: nums = [10,4,-8,7]
Output: 2
-Explanation:
+Explanation:
There are three ways of splitting nums into two non-empty parts:
- Split nums at index 0. Then, the first part is [10], and its sum is 10. The second part is [4,-8,7], and its sum is 3. Since 10 >= 3, i = 0 is a valid split.
- Split nums at index 1. Then, the first part is [10,4], and its sum is 14. The second part is [-8,7], and its sum is -1. Since 14 >= -1, i = 1 is a valid split.
@@ -49,9 +49,9 @@ Thus, the number of valid splits in nums is 2.
Input: nums = [2,3,1,0]
Output: 2
-Explanation:
+Explanation:
There are two valid splits in nums:
-- Split nums at index 1. Then, the first part is [2,3], and its sum is 5. The second part is [1,0], and its sum is 1. Since 5 >= 1, i = 1 is a valid split.
+- Split nums at index 1. Then, the first part is [2,3], and its sum is 5. The second part is [1,0], and its sum is 1. Since 5 >= 1, i = 1 is a valid split.
- Split nums at index 2. Then, the first part is [2,3,1], and its sum is 6. The second part is [0], and its sum is 0. Since 6 >= 0, i = 2 is a valid split.
diff --git a/solution/2500-2599/2526.Find Consecutive Integers from a Data Stream/README.md b/solution/2500-2599/2526.Find Consecutive Integers from a Data Stream/README.md
index 75ccdec366088..86af0b96f6da1 100644
--- a/solution/2500-2599/2526.Find Consecutive Integers from a Data Stream/README.md
+++ b/solution/2500-2599/2526.Find Consecutive Integers from a Data Stream/README.md
@@ -43,7 +43,7 @@ tags:
[null, false, false, true, false]
解释:
-DataStream dataStream = new DataStream(4, 3); // value = 4, k = 3
+DataStream dataStream = new DataStream(4, 3); // value = 4, k = 3
dataStream.consec(4); // 数据流中只有 1 个整数,所以返回 False 。
dataStream.consec(4); // 数据流中只有 2 个整数
// 由于 2 小于 k ,返回 False 。
diff --git a/solution/2500-2599/2526.Find Consecutive Integers from a Data Stream/README_EN.md b/solution/2500-2599/2526.Find Consecutive Integers from a Data Stream/README_EN.md
index 4810f74a3c607..e0d5e0651a7b2 100644
--- a/solution/2500-2599/2526.Find Consecutive Integers from a Data Stream/README_EN.md
+++ b/solution/2500-2599/2526.Find Consecutive Integers from a Data Stream/README_EN.md
@@ -42,11 +42,11 @@ tags:
[null, false, false, true, false]
Explanation
-DataStream dataStream = new DataStream(4, 3); //value = 4, k = 3
-dataStream.consec(4); // Only 1 integer is parsed, so returns False.
+DataStream dataStream = new DataStream(4, 3); //value = 4, k = 3
+dataStream.consec(4); // Only 1 integer is parsed, so returns False.
dataStream.consec(4); // Only 2 integers are parsed.
- // Since 2 is less than k, returns False.
-dataStream.consec(4); // The 3 integers parsed are all equal to value, so returns True.
+ // Since 2 is less than k, returns False.
+dataStream.consec(4); // The 3 integers parsed are all equal to value, so returns True.
dataStream.consec(3); // The last k integers parsed in the stream are [4,4,3].
// Since 3 is not equal to value, it returns False.
diff --git a/solution/2500-2599/2528.Maximize the Minimum Powered City/README_EN.md b/solution/2500-2599/2528.Maximize the Minimum Powered City/README_EN.md
index 88b70cc92173b..5092ff56c0de0 100644
--- a/solution/2500-2599/2528.Maximize the Minimum Powered City/README_EN.md
+++ b/solution/2500-2599/2528.Maximize the Minimum Powered City/README_EN.md
@@ -45,8 +45,8 @@ tags:
Input: stations = [1,2,4,5,0], r = 1, k = 2
Output: 5
-Explanation:
-One of the optimal ways is to install both the power stations at city 1.
+Explanation:
+One of the optimal ways is to install both the power stations at city 1.
So stations will become [1,4,4,5,0].
- City 0 is provided by 1 + 4 = 5 power stations.
- City 1 is provided by 1 + 4 + 4 = 9 power stations.
@@ -62,7 +62,7 @@ Since it is not possible to obtain a larger power, we return 5.
Input: stations = [4,4,4,4], r = 0, k = 3
Output: 4
-Explanation:
+Explanation:
It can be proved that we cannot make the minimum power of a city greater than 4.
diff --git a/solution/2500-2599/2530.Maximal Score After Applying K Operations/README_EN.md b/solution/2500-2599/2530.Maximal Score After Applying K Operations/README_EN.md
index a1dcfe3aa869e..8e6240a02b140 100644
--- a/solution/2500-2599/2530.Maximal Score After Applying K Operations/README_EN.md
+++ b/solution/2500-2599/2530.Maximal Score After Applying K Operations/README_EN.md
@@ -51,7 +51,7 @@ tags:
Explanation: You can do the following operations:
Operation 1: Select i = 1, so nums becomes [1,4,3,3,3]. Your score increases by 10.
Operation 2: Select i = 1, so nums becomes [1,2,3,3,3]. Your score increases by 4.
-Operation 3: Select i = 2, so nums becomes [1,1,1,3,3]. Your score increases by 3.
+Operation 3: Select i = 2, so nums becomes [1,2,1,3,3]. Your score increases by 3.
The final score is 10 + 4 + 3 = 17.
diff --git a/solution/3200-3299/3222.Find the Winning Player in Coin Game/README.md b/solution/3200-3299/3222.Find the Winning Player in Coin Game/README.md
index d2d5efced4dcf..e5804e09db059 100644
--- a/solution/3200-3299/3222.Find the Winning Player in Coin Game/README.md
+++ b/solution/3200-3299/3222.Find the Winning Player in Coin Game/README.md
@@ -22,7 +22,7 @@ tags:
给你两个 正 整数 x
和 y
,分别表示价值为 75 和 10 的硬币的数目。
-Alice 和 Bob 正在玩一个游戏。每一轮中,Alice 先进行操作,Bob 后操作。每次操作中,玩家需要拿出价值 总和 为 115 的硬币。如果一名玩家无法执行此操作,那么这名玩家 输掉 游戏。
+Alice 和 Bob 正在玩一个游戏。每一轮中,Alice 先进行操作,Bob 后操作。每次操作中,玩家需要拿走价值 总和 为 115 的硬币。如果一名玩家无法执行此操作,那么这名玩家 输掉 游戏。
两名玩家都采取 最优 策略,请你返回游戏的赢家。
diff --git a/solution/3300-3399/3336.Find the Number of Subsequences With Equal GCD/README.md b/solution/3300-3399/3336.Find the Number of Subsequences With Equal GCD/README.md
index cd23fec634515..c5f9b8468c147 100644
--- a/solution/3300-3399/3336.Find the Number of Subsequences With Equal GCD/README.md
+++ b/solution/3300-3399/3336.Find the Number of Subsequences With Equal GCD/README.md
@@ -21,7 +21,7 @@ tags:
给你一个整数数组 nums
。
-请你统计所有满足一下条件的 非空 子序列 对 (seq1, seq2)
的数量:
+请你统计所有满足以下条件的 非空 子序列 对 (seq1, seq2)
的数量:
- 子序列
seq1
和 seq2
不相交,意味着 nums
中 不存在 同时出现在两个序列中的下标。
diff --git a/solution/3300-3399/3344.Maximum Sized Array/README.md b/solution/3300-3399/3344.Maximum Sized Array/README.md
new file mode 100644
index 0000000000000..8f55792193bfc
--- /dev/null
+++ b/solution/3300-3399/3344.Maximum Sized Array/README.md
@@ -0,0 +1,255 @@
+---
+comments: true
+difficulty: 中等
+edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3344.Maximum%20Sized%20Array/README.md
+tags:
+ - 位运算
+ - 二分查找
+---
+
+
+
+# [3344. 最大尺寸数组 🔒](https://leetcode.cn/problems/maximum-sized-array)
+
+[English Version](/solution/3300-3399/3344.Maximum%20Sized%20Array/README_EN.md)
+
+## 题目描述
+
+
+
+给定一个正整数 s
,令 A
为一个 n × n × n
的三维数组,其中每个元素 A[i][j][k]
定义为:
+
+
+ A[i][j][k] = i * (j OR k)
,其中 0 <= i, j, k < n
。
+
+
+返回使数组 A
中所有元素的和不超过 s
的 最大的 n
。
+
+
+
+示例 1:
+
+
+
输入:s = 10
+
+
输出:2
+
+
解释:
+
+
+ n = 2
时数组 A
的元素:
+
+
+ A[0][0][0] = 0 * (0 OR 0) = 0
+ A[0][0][1] = 0 * (0 OR 1) = 0
+ A[0][1][0] = 0 * (1 OR 0) = 0
+ A[0][1][1] = 0 * (1 OR 1) = 0
+ A[1][0][0] = 1 * (0 OR 0) = 0
+ A[1][0][1] = 1 * (0 OR 1) = 1
+ A[1][1][0] = 1 * (1 OR 0) = 1
+ A[1][1][1] = 1 * (1 OR 1) = 1
+
+
+ - 数组
A
中元素的总和为 3,没有超过 10,所以 n
的最大值为 2。
+
+
+
+
+示例 2:
+
+
+
输入:s = 0
+
+
输出:1
+
+
解释:
+
+
+ n = 1
时数组 A
的元素:
+
+
+ A[0][0][0] = 0 * (0 OR 0) = 0
+
+
+ - 数组
A
中元素的总和为 0,没有超过 0,所以 n
的最大值为 1。
+
+
+
+
+
+
+提示:
+
+
+
+
+
+## 解法
+
+
+
+### 方法一:预处理 + 二分查找
+
+我们可以粗略估算出 $n$ 的最大值,对于 $j \lor k$,结果的和大致为 $n^2 (n - 1) / 2$,再与 $i \in [0, n)$ 的每个 $i$ 相乘,结果约等于 $(n-1)^5 / 4$,要使得 $(n - 1)^5 / 4 \leq s$,那么 $n \leq 1320$。
+
+因此,我们不妨预处理出 $f[n] = \sum_{i=0}^{n-1} \sum_{j=0}^{i} (i \lor j)$,然后使用二分查找找到最大的 $n$,使得 $f[n-1] \cdot (n-1) \cdot n / 2 \leq s$。
+
+时间复杂度方面,预处理的时间复杂度为 $O(n^2)$,二分查找的时间复杂度为 $O(\log n)$,因此总时间复杂度为 $O(n^2 + \log n)$。空间复杂度为 $O(n)$。
+
+
+
+#### Python3
+
+```python
+mx = 1330
+f = [0] * mx
+for i in range(1, mx):
+ f[i] = f[i - 1] + i
+ for j in range(i):
+ f[i] += 2 * (i | j)
+
+
+class Solution:
+ def maxSizedArray(self, s: int) -> int:
+ l, r = 1, mx
+ while l < r:
+ m = (l + r + 1) >> 1
+ if f[m - 1] * (m - 1) * m // 2 <= s:
+ l = m
+ else:
+ r = m - 1
+ return l
+```
+
+#### Java
+
+```java
+class Solution {
+ private static final int MX = 1330;
+ private static final long[] f = new long[MX];
+ static {
+ for (int i = 1; i < MX; ++i) {
+ f[i] = f[i - 1] + i;
+ for (int j = 0; j < i; ++j) {
+ f[i] += 2 * (i | j);
+ }
+ }
+ }
+ public int maxSizedArray(long s) {
+ int l = 1, r = MX;
+ while (l < r) {
+ int m = (l + r + 1) >> 1;
+ if (f[m - 1] * (m - 1) * m / 2 <= s) {
+ l = m;
+ } else {
+ r = m - 1;
+ }
+ }
+ return l;
+ }
+}
+```
+
+#### C++
+
+```cpp
+const int MX = 1330;
+long long f[MX];
+auto init = [] {
+ f[0] = 0;
+ for (int i = 1; i < MX; ++i) {
+ f[i] = f[i - 1] + i;
+ for (int j = 0; j < i; ++j) {
+ f[i] += 2 * (i | j);
+ }
+ }
+ return 0;
+}();
+
+class Solution {
+public:
+ int maxSizedArray(long long s) {
+ int l = 1, r = MX;
+ while (l < r) {
+ int m = (l + r + 1) >> 1;
+ if (f[m - 1] * (m - 1) * m / 2 <= s) {
+ l = m;
+ } else {
+ r = m - 1;
+ }
+ }
+ return l;
+ }
+};
+```
+
+#### Go
+
+```go
+const MX = 1330
+
+var f [MX]int64
+
+func init() {
+ f[0] = 0
+ for i := 1; i < MX; i++ {
+ f[i] = f[i-1] + int64(i)
+ for j := 0; j < i; j++ {
+ f[i] += 2 * int64(i|j)
+ }
+ }
+}
+
+func maxSizedArray(s int64) int {
+ l, r := 1, MX
+ for l < r {
+ m := (l + r + 1) >> 1
+ if f[m-1]*int64(m-1)*int64(m)/2 <= s {
+ l = m
+ } else {
+ r = m - 1
+ }
+ }
+ return l
+}
+```
+
+#### TypeScript
+
+```ts
+const MX = 1330;
+const f: bigint[] = Array(MX).fill(0n);
+(() => {
+ f[0] = 0n;
+ for (let i = 1; i < MX; i++) {
+ f[i] = f[i - 1] + BigInt(i);
+ for (let j = 0; j < i; j++) {
+ f[i] += BigInt(2) * BigInt(i | j);
+ }
+ }
+})();
+
+function maxSizedArray(s: number): number {
+ let l = 1,
+ r = MX;
+ const target = BigInt(s);
+
+ while (l < r) {
+ const m = (l + r + 1) >> 1;
+ if ((f[m - 1] * BigInt(m - 1) * BigInt(m)) / BigInt(2) <= target) {
+ l = m;
+ } else {
+ r = m - 1;
+ }
+ }
+ return l;
+}
+```
+
+
+
+
+
+
diff --git a/solution/3300-3399/3344.Maximum Sized Array/README_EN.md b/solution/3300-3399/3344.Maximum Sized Array/README_EN.md
new file mode 100644
index 0000000000000..54001e57802e6
--- /dev/null
+++ b/solution/3300-3399/3344.Maximum Sized Array/README_EN.md
@@ -0,0 +1,253 @@
+---
+comments: true
+difficulty: Medium
+edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3344.Maximum%20Sized%20Array/README_EN.md
+tags:
+ - Bit Manipulation
+ - Binary Search
+---
+
+
+
+# [3344. Maximum Sized Array 🔒](https://leetcode.com/problems/maximum-sized-array)
+
+[中文文档](/solution/3300-3399/3344.Maximum%20Sized%20Array/README.md)
+
+## Description
+
+
+
+Given a positive integer s
, let A
be a 3D array of dimensions n × n × n
, where each element A[i][j][k]
is defined as:
+
+
+ A[i][j][k] = i * (j OR k)
, where 0 <= i, j, k < n
.
+
+
+Return the maximum possible value of n
such that the sum of all elements in array A
does not exceed s
.
+
+
+Example 1:
+
+
+
Input: s = 10
+
+
Output: 2
+
+
Explanation:
+
+
+ - Elements of the array
A
for n = 2
:
+
+
+ A[0][0][0] = 0 * (0 OR 0) = 0
+ A[0][0][1] = 0 * (0 OR 1) = 0
+ A[0][1][0] = 0 * (1 OR 0) = 0
+ A[0][1][1] = 0 * (1 OR 1) = 0
+ A[1][0][0] = 1 * (0 OR 0) = 0
+ A[1][0][1] = 1 * (0 OR 1) = 1
+ A[1][1][0] = 1 * (1 OR 0) = 1
+ A[1][1][1] = 1 * (1 OR 1) = 1
+
+
+ - The total sum of the elements in array
A
is 3, which does not exceed 10, so the maximum possible value of n
is 2.
+
+
+
+
+Example 2:
+
+
+
Input: s = 0
+
+
Output: 1
+
+
Explanation:
+
+
+ - Elements of the array
A
for n = 1
:
+
+
+ A[0][0][0] = 0 * (0 OR 0) = 0
+
+
+ - The total sum of the elements in array
A
is 0, which does not exceed 0, so the maximum possible value of n
is 1.
+
+
+
+
+
+Constraints:
+
+
+
+
+
+## Solutions
+
+
+
+### Solution 1: Preprocessing + Binary Search
+
+We can roughly estimate the maximum value of $n$. For $j \lor k$, the sum of the results is approximately $n^2 (n - 1) / 2$. Multiplying this by each $i \in [0, n)$, the result is approximately $(n-1)^5 / 4$. To ensure $(n - 1)^5 / 4 \leq s$, we have $n \leq 1320$.
+
+Therefore, we can preprocess $f[n] = \sum_{i=0}^{n-1} \sum_{j=0}^{i} (i \lor j)$, and then use binary search to find the largest $n$ such that $f[n-1] \cdot (n-1) \cdot n / 2 \leq s$.
+
+In terms of time complexity, the preprocessing has a time complexity of $O(n^2)$, and the binary search has a time complexity of $O(\log n)$. Therefore, the total time complexity is $O(n^2 + \log n)$. The space complexity is $O(n)$.
+
+
+
+#### Python3
+
+```python
+mx = 1330
+f = [0] * mx
+for i in range(1, mx):
+ f[i] = f[i - 1] + i
+ for j in range(i):
+ f[i] += 2 * (i | j)
+
+
+class Solution:
+ def maxSizedArray(self, s: int) -> int:
+ l, r = 1, mx
+ while l < r:
+ m = (l + r + 1) >> 1
+ if f[m - 1] * (m - 1) * m // 2 <= s:
+ l = m
+ else:
+ r = m - 1
+ return l
+```
+
+#### Java
+
+```java
+class Solution {
+ private static final int MX = 1330;
+ private static final long[] f = new long[MX];
+ static {
+ for (int i = 1; i < MX; ++i) {
+ f[i] = f[i - 1] + i;
+ for (int j = 0; j < i; ++j) {
+ f[i] += 2 * (i | j);
+ }
+ }
+ }
+ public int maxSizedArray(long s) {
+ int l = 1, r = MX;
+ while (l < r) {
+ int m = (l + r + 1) >> 1;
+ if (f[m - 1] * (m - 1) * m / 2 <= s) {
+ l = m;
+ } else {
+ r = m - 1;
+ }
+ }
+ return l;
+ }
+}
+```
+
+#### C++
+
+```cpp
+const int MX = 1330;
+long long f[MX];
+auto init = [] {
+ f[0] = 0;
+ for (int i = 1; i < MX; ++i) {
+ f[i] = f[i - 1] + i;
+ for (int j = 0; j < i; ++j) {
+ f[i] += 2 * (i | j);
+ }
+ }
+ return 0;
+}();
+
+class Solution {
+public:
+ int maxSizedArray(long long s) {
+ int l = 1, r = MX;
+ while (l < r) {
+ int m = (l + r + 1) >> 1;
+ if (f[m - 1] * (m - 1) * m / 2 <= s) {
+ l = m;
+ } else {
+ r = m - 1;
+ }
+ }
+ return l;
+ }
+};
+```
+
+#### Go
+
+```go
+const MX = 1330
+
+var f [MX]int64
+
+func init() {
+ f[0] = 0
+ for i := 1; i < MX; i++ {
+ f[i] = f[i-1] + int64(i)
+ for j := 0; j < i; j++ {
+ f[i] += 2 * int64(i|j)
+ }
+ }
+}
+
+func maxSizedArray(s int64) int {
+ l, r := 1, MX
+ for l < r {
+ m := (l + r + 1) >> 1
+ if f[m-1]*int64(m-1)*int64(m)/2 <= s {
+ l = m
+ } else {
+ r = m - 1
+ }
+ }
+ return l
+}
+```
+
+#### TypeScript
+
+```ts
+const MX = 1330;
+const f: bigint[] = Array(MX).fill(0n);
+(() => {
+ f[0] = 0n;
+ for (let i = 1; i < MX; i++) {
+ f[i] = f[i - 1] + BigInt(i);
+ for (let j = 0; j < i; j++) {
+ f[i] += BigInt(2) * BigInt(i | j);
+ }
+ }
+})();
+
+function maxSizedArray(s: number): number {
+ let l = 1,
+ r = MX;
+ const target = BigInt(s);
+
+ while (l < r) {
+ const m = (l + r + 1) >> 1;
+ if ((f[m - 1] * BigInt(m - 1) * BigInt(m)) / BigInt(2) <= target) {
+ l = m;
+ } else {
+ r = m - 1;
+ }
+ }
+ return l;
+}
+```
+
+
+
+
+
+
diff --git a/solution/3300-3399/3344.Maximum Sized Array/Solution.cpp b/solution/3300-3399/3344.Maximum Sized Array/Solution.cpp
new file mode 100644
index 0000000000000..d1a8d8deea977
--- /dev/null
+++ b/solution/3300-3399/3344.Maximum Sized Array/Solution.cpp
@@ -0,0 +1,28 @@
+const int MX = 1330;
+long long f[MX];
+auto init = [] {
+ f[0] = 0;
+ for (int i = 1; i < MX; ++i) {
+ f[i] = f[i - 1] + i;
+ for (int j = 0; j < i; ++j) {
+ f[i] += 2 * (i | j);
+ }
+ }
+ return 0;
+}();
+
+class Solution {
+public:
+ int maxSizedArray(long long s) {
+ int l = 1, r = MX;
+ while (l < r) {
+ int m = (l + r + 1) >> 1;
+ if (f[m - 1] * (m - 1) * m / 2 <= s) {
+ l = m;
+ } else {
+ r = m - 1;
+ }
+ }
+ return l;
+ }
+};
diff --git a/solution/3300-3399/3344.Maximum Sized Array/Solution.go b/solution/3300-3399/3344.Maximum Sized Array/Solution.go
new file mode 100644
index 0000000000000..0a3a0e4a43373
--- /dev/null
+++ b/solution/3300-3399/3344.Maximum Sized Array/Solution.go
@@ -0,0 +1,26 @@
+const MX = 1330
+
+var f [MX]int64
+
+func init() {
+ f[0] = 0
+ for i := 1; i < MX; i++ {
+ f[i] = f[i-1] + int64(i)
+ for j := 0; j < i; j++ {
+ f[i] += 2 * int64(i|j)
+ }
+ }
+}
+
+func maxSizedArray(s int64) int {
+ l, r := 1, MX
+ for l < r {
+ m := (l + r + 1) >> 1
+ if f[m-1]*int64(m-1)*int64(m)/2 <= s {
+ l = m
+ } else {
+ r = m - 1
+ }
+ }
+ return l
+}
diff --git a/solution/3300-3399/3344.Maximum Sized Array/Solution.java b/solution/3300-3399/3344.Maximum Sized Array/Solution.java
new file mode 100644
index 0000000000000..6662455051b7c
--- /dev/null
+++ b/solution/3300-3399/3344.Maximum Sized Array/Solution.java
@@ -0,0 +1,24 @@
+class Solution {
+ private static final int MX = 1330;
+ private static final long[] f = new long[MX];
+ static {
+ for (int i = 1; i < MX; ++i) {
+ f[i] = f[i - 1] + i;
+ for (int j = 0; j < i; ++j) {
+ f[i] += 2 * (i | j);
+ }
+ }
+ }
+ public int maxSizedArray(long s) {
+ int l = 1, r = MX;
+ while (l < r) {
+ int m = (l + r + 1) >> 1;
+ if (f[m - 1] * (m - 1) * m / 2 <= s) {
+ l = m;
+ } else {
+ r = m - 1;
+ }
+ }
+ return l;
+ }
+}
diff --git a/solution/3300-3399/3344.Maximum Sized Array/Solution.py b/solution/3300-3399/3344.Maximum Sized Array/Solution.py
new file mode 100644
index 0000000000000..f078b64bf6734
--- /dev/null
+++ b/solution/3300-3399/3344.Maximum Sized Array/Solution.py
@@ -0,0 +1,18 @@
+mx = 1330
+f = [0] * mx
+for i in range(1, mx):
+ f[i] = f[i - 1] + i
+ for j in range(i):
+ f[i] += 2 * (i | j)
+
+
+class Solution:
+ def maxSizedArray(self, s: int) -> int:
+ l, r = 1, mx
+ while l < r:
+ m = (l + r + 1) >> 1
+ if f[m - 1] * (m - 1) * m // 2 <= s:
+ l = m
+ else:
+ r = m - 1
+ return l
diff --git a/solution/3300-3399/3344.Maximum Sized Array/Solution.ts b/solution/3300-3399/3344.Maximum Sized Array/Solution.ts
new file mode 100644
index 0000000000000..bb3fefda407fc
--- /dev/null
+++ b/solution/3300-3399/3344.Maximum Sized Array/Solution.ts
@@ -0,0 +1,27 @@
+const MX = 1330;
+const f: bigint[] = Array(MX).fill(0n);
+(() => {
+ f[0] = 0n;
+ for (let i = 1; i < MX; i++) {
+ f[i] = f[i - 1] + BigInt(i);
+ for (let j = 0; j < i; j++) {
+ f[i] += BigInt(2) * BigInt(i | j);
+ }
+ }
+})();
+
+function maxSizedArray(s: number): number {
+ let l = 1,
+ r = MX;
+ const target = BigInt(s);
+
+ while (l < r) {
+ const m = (l + r + 1) >> 1;
+ if ((f[m - 1] * BigInt(m - 1) * BigInt(m)) / BigInt(2) <= target) {
+ l = m;
+ } else {
+ r = m - 1;
+ }
+ }
+ return l;
+}
diff --git a/solution/README.md b/solution/README.md
index f3dd02bf42898..f3e2c782c7f05 100644
--- a/solution/README.md
+++ b/solution/README.md
@@ -3354,6 +3354,7 @@
| 3341 | [到达最后一个房间的最少时间 I](/solution/3300-3399/3341.Find%20Minimum%20Time%20to%20Reach%20Last%20Room%20I/README.md) | `图`,`数组`,`矩阵`,`最短路`,`堆(优先队列)` | 中等 | 第 422 场周赛 |
| 3342 | [到达最后一个房间的最少时间 II](/solution/3300-3399/3342.Find%20Minimum%20Time%20to%20Reach%20Last%20Room%20II/README.md) | `图`,`数组`,`矩阵`,`最短路`,`堆(优先队列)` | 中等 | 第 422 场周赛 |
| 3343 | [统计平衡排列的数目](/solution/3300-3399/3343.Count%20Number%20of%20Balanced%20Permutations/README.md) | `数学`,`字符串`,`动态规划`,`组合数学` | 困难 | 第 422 场周赛 |
+| 3344 | [最大尺寸数组](/solution/3300-3399/3344.Maximum%20Sized%20Array/README.md) | `位运算`,`二分查找` | 中等 | 🔒 |
## 版权
diff --git a/solution/README_EN.md b/solution/README_EN.md
index 6e495fc3d19d6..da2ef96c04c13 100644
--- a/solution/README_EN.md
+++ b/solution/README_EN.md
@@ -3352,6 +3352,7 @@ Press Control + F(or Command + F on
| 3341 | [Find Minimum Time to Reach Last Room I](/solution/3300-3399/3341.Find%20Minimum%20Time%20to%20Reach%20Last%20Room%20I/README_EN.md) | `Graph`,`Array`,`Matrix`,`Shortest Path`,`Heap (Priority Queue)` | Medium | Weekly Contest 422 |
| 3342 | [Find Minimum Time to Reach Last Room II](/solution/3300-3399/3342.Find%20Minimum%20Time%20to%20Reach%20Last%20Room%20II/README_EN.md) | `Graph`,`Array`,`Matrix`,`Shortest Path`,`Heap (Priority Queue)` | Medium | Weekly Contest 422 |
| 3343 | [Count Number of Balanced Permutations](/solution/3300-3399/3343.Count%20Number%20of%20Balanced%20Permutations/README_EN.md) | `Math`,`String`,`Dynamic Programming`,`Combinatorics` | Hard | Weekly Contest 422 |
+| 3344 | [Maximum Sized Array](/solution/3300-3399/3344.Maximum%20Sized%20Array/README_EN.md) | `Bit Manipulation`,`Binary Search` | Medium | 🔒 |
## Copyright