Skip to content

Merge from master #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2,107 commits into
base: longsq
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
2107 commits
Select commit Hold shift + click to select a range
6a5e57b
test: 1504 solution
QuBenhao Jun 15, 2025
c7d112d
test: 316 solution
QuBenhao Jun 15, 2025
9774a03
test: 3582, 3583, 3584, 3585 solution
QuBenhao Jun 15, 2025
aca2ac6
test: 3582, 3583, 3584, 3585 solution
QuBenhao Jun 15, 2025
604013c
test: 3582, 3583, 3584, 3585 solution
QuBenhao Jun 15, 2025
7b202d8
test: 3582, 3583, 3584, 3585 solution
QuBenhao Jun 15, 2025
22c7f95
test: 1732 solution
QuBenhao Jun 15, 2025
a553d8f
test: [20250616] Add (2016)
actions-user Jun 15, 2025
96c0083
test: 2016 solution
QuBenhao Jun 15, 2025
bc2ce0e
test: add 321
QuBenhao Jun 15, 2025
ae709b8
test: 321 solution
QuBenhao Jun 16, 2025
5d0057a
test: 321
QuBenhao Jun 16, 2025
bb5ad88
test: 402 solution
QuBenhao Jun 16, 2025
2400f65
test: go build ignore
QuBenhao Jun 16, 2025
70b8af3
test: 1206 solution
QuBenhao Jun 16, 2025
404023d
test: 1206 solution
QuBenhao Jun 16, 2025
d88730c
fix: java groovy path on Windows
QuBenhao Jun 16, 2025
748fa1c
10.1.1
Jun 16, 2025
1c381e6
test: [20250617] Add (3405)
actions-user Jun 16, 2025
15f6fe5
test: 3405 solution
QuBenhao Jun 16, 2025
9ceb2ea
fix: use path.join for file paths in tests
QuBenhao Jun 17, 2025
d85887a
test: add 808, 813
QuBenhao Jun 17, 2025
2d593ea
fix: handle old python
QuBenhao Jun 17, 2025
ad89ad7
test: 808 solution
QuBenhao Jun 17, 2025
dffb5c8
test: 813 solution
QuBenhao Jun 17, 2025
a28bd3a
fix: maven problem folder and bazel plans
QuBenhao Jun 17, 2025
4f4e305
10.1.2
Jun 17, 2025
5199224
test: 813 solution
QuBenhao Jun 17, 2025
b36683f
test: [20250618] Add (2966)
actions-user Jun 17, 2025
9d10421
test: 2966 solution
QuBenhao Jun 18, 2025
2f38636
test: 1 solution
QuBenhao Jun 18, 2025
dd8c79f
test: 791 solution
QuBenhao Jun 18, 2025
cc41073
test: 21 cpp memory
QuBenhao Jun 18, 2025
fffdd6d
test: 24, 25 cpp memory
QuBenhao Jun 18, 2025
6637ea5
test: [20250619] Add (2294)
actions-user Jun 18, 2025
5075d66
test: 2294 solution
QuBenhao Jun 18, 2025
103d3e4
test: 2294 solution
QuBenhao Jun 18, 2025
a247bba
test: reformat
QuBenhao Jun 19, 2025
b47be1d
test: cpp
QuBenhao Jun 19, 2025
6a12133
test: 775 solution
QuBenhao Jun 19, 2025
0347a36
test: 775
QuBenhao Jun 19, 2025
b2df641
test: [20250620] Add (3443)
actions-user Jun 19, 2025
53e7921
test: 3443 solution
QuBenhao Jun 19, 2025
bc40a9b
test: 879 solution
QuBenhao Jun 20, 2025
09b76ab
test: 864 solution
QuBenhao Jun 20, 2025
8e8c28a
test: [20250621] Add (3085)
actions-user Jun 20, 2025
20d5fc6
test: 3085 solution
QuBenhao Jun 21, 2025
c339a4a
test: 2385 solution
QuBenhao Jun 21, 2025
dfd89d7
test: 978 solution
QuBenhao Jun 21, 2025
fd36ad8
test: 1662 solution
QuBenhao Jun 21, 2025
a8b28d0
test: 1662 template
QuBenhao Jun 21, 2025
ce94dbc
test: [20250622] Add (2138)
actions-user Jun 21, 2025
274ebc6
test: doc
QuBenhao Jun 21, 2025
2a1d5fc
test: 2138 solution
QuBenhao Jun 21, 2025
74d3141
test: add bi-weekly contest #159
QuBenhao Jun 21, 2025
d607b58
test: 3587, 3588, 3589, 3590 solution
QuBenhao Jun 21, 2025
7125804
test: 3587, 3589 solution
QuBenhao Jun 22, 2025
964b7cf
test: add weekly contest #455
QuBenhao Jun 22, 2025
b12649f
test: 3591, 3592, 3593, 3594 solution
QuBenhao Jun 22, 2025
77fcc45
test: 3591, 3592, 3593, 3594 solution (unfinished)
QuBenhao Jun 22, 2025
f8282e3
test: 3593 solution
QuBenhao Jun 22, 2025
49dbafc
test: 3593 solution
QuBenhao Jun 22, 2025
a72c260
test: [20250623] Add (2081)
actions-user Jun 22, 2025
000884e
test: 2081 solution
QuBenhao Jun 23, 2025
8cd1be0
test: 3594 solution
QuBenhao Jun 23, 2025
9ae741e
test: 1704 solution
QuBenhao Jun 23, 2025
c809158
test: 816 solution
QuBenhao Jun 23, 2025
c728105
test: [20250624] Add (2200)
actions-user Jun 23, 2025
90e28e4
test: 2200 solution
QuBenhao Jun 23, 2025
4f89b85
test: 891 solution
QuBenhao Jun 24, 2025
6b5fd95
test: [20250625] Add (2040)
actions-user Jun 24, 2025
df162ad
test: 2040 solution
QuBenhao Jun 25, 2025
cf88b50
feat: CMake support (#161)
QuBenhao Jun 25, 2025
84d7de9
10.2.0
Jun 25, 2025
d21a63d
test: 1802, 2040 solution
QuBenhao Jun 25, 2025
60e6314
test: 1802, 2040 solution
QuBenhao Jun 25, 2025
a2507d9
test: 1802, 2040 solution
QuBenhao Jun 25, 2025
3a04222
test: [20250626] Add (2311)
actions-user Jun 25, 2025
ebbd5c6
test: 2311 solution
QuBenhao Jun 25, 2025
dc04664
test: 799 add
QuBenhao Jun 26, 2025
526d455
test: [20250627] Add (2014)
actions-user Jun 26, 2025
b4829e3
test: 799 solution
QuBenhao Jun 27, 2025
eca2cb2
test: 2014 solution
QuBenhao Jun 27, 2025
aee0e1e
test: 2240 solution
QuBenhao Jun 27, 2025
30a9307
test: 1106 solution
QuBenhao Jun 27, 2025
6a7d490
test: 228 solution
QuBenhao Jun 27, 2025
4af853a
test: 1124 solution
QuBenhao Jun 27, 2025
8a82d97
test: 1130 solution
QuBenhao Jun 27, 2025
3ae14a1
test: 496 solution
QuBenhao Jun 27, 2025
04135fe
test: [20250628] Add (2099)
actions-user Jun 27, 2025
a709549
test: 2099 solution
QuBenhao Jun 28, 2025
8d1cf5b
test: 2030 solution
QuBenhao Jun 28, 2025
360fda4
test: 213 solution
QuBenhao Jun 28, 2025
a4667d5
test: ignore
QuBenhao Jun 28, 2025
e636d0a
test: 1678 solution
QuBenhao Jun 28, 2025
ab9ce26
test: 1662 ignore
QuBenhao Jun 28, 2025
4a09821
test: [20250629] Add (1498)
actions-user Jun 28, 2025
d03ea3d
test: 1498 solution
QuBenhao Jun 28, 2025
7a9e189
test: 2818 solution
QuBenhao Jun 29, 2025
03bbc88
docs: update templates
QuBenhao Jun 29, 2025
e49d5ad
test: 3597, 3598, 3599, 3600 solution
QuBenhao Jun 29, 2025
b2578c0
test: 3597, 3598, 3599, 3600 solution
QuBenhao Jun 29, 2025
aff6604
test: 3597, 3598, 3599, 3600 solution
QuBenhao Jun 29, 2025
bfbc790
test: 3597, 3598, 3599, 3600 solution
QuBenhao Jun 29, 2025
24fc678
test: 1790 solution
QuBenhao Jun 29, 2025
7cf4c92
test: [20250630] Add (594)
actions-user Jun 29, 2025
c747291
test: 594 solution
QuBenhao Jun 29, 2025
4f24962
test: 862 solution
QuBenhao Jun 29, 2025
a3241c5
test: 209 solution
QuBenhao Jun 29, 2025
aafed6a
test: 450 solution
QuBenhao Jun 30, 2025
50d51c4
test: 784 solution
QuBenhao Jun 30, 2025
105818a
test: [20250701] Add (3330)
actions-user Jun 30, 2025
faf8be0
test: 3330 solution
QuBenhao Jun 30, 2025
4ae77c0
test: 3331 solution
QuBenhao Jul 1, 2025
4f9ce72
test: 3332 solution
QuBenhao Jul 1, 2025
b0ae265
test: 3333 solution
QuBenhao Jul 1, 2025
44b2ea5
test: 779 solution
QuBenhao Jul 1, 2025
ecfff6f
fix: daily_submission script
QuBenhao Jul 1, 2025
aa39d47
fix: daily_submission script
QuBenhao Jul 1, 2025
231211f
test: remove extra rust
QuBenhao Jul 1, 2025
faaa5f8
test: 779 solution
QuBenhao Jul 1, 2025
93a646a
test: [20250702] Add (3333)
actions-user Jul 1, 2025
2976209
test: 904 solution
QuBenhao Jul 2, 2025
5a1d53e
test: [20250703] Add (3304)
actions-user Jul 2, 2025
edd2dd7
test: 3304 solution
QuBenhao Jul 2, 2025
c5ec7f8
test: add function test
QuBenhao Jul 2, 2025
c7408e8
test: 1620 solution
QuBenhao Jul 3, 2025
0193cf2
test: [20250704] Add (3307)
actions-user Jul 3, 2025
b1c4057
test: 3307 solution
QuBenhao Jul 3, 2025
8dcf9b7
feat: 162 windows support (#163)
QuBenhao Jul 4, 2025
f765f6a
10.3.0
Jul 4, 2025
1da9d8b
test: [20250705] Add (1394)
actions-user Jul 4, 2025
61480f1
test: 1394 solution
QuBenhao Jul 5, 2025
865217c
test: 1784 solution
QuBenhao Jul 5, 2025
99913cc
test: 1784 solution
QuBenhao Jul 5, 2025
4476ea9
test: [20250706] Add (1865)
actions-user Jul 5, 2025
003b383
test: codeforces contest/475/D
QuBenhao Jul 5, 2025
78029f5
test: 1865 solution
QuBenhao Jul 5, 2025
942ff37
test: 3602, 3603, 3604, 3605 solution
QuBenhao Jul 6, 2025
432492d
fix: problemsetQuestionListV2
QuBenhao Jul 6, 2025
fde36c6
10.3.1
Jul 6, 2025
ba6a172
test: 3602, 3603, 3604, 3605 solution
QuBenhao Jul 6, 2025
f327325
docs: templates.md
QuBenhao Jul 6, 2025
1d1800b
test: 3602, 3603, 3604, 3605 solution
QuBenhao Jul 6, 2025
597415f
test: 3606, 3607, 3608, 3609
QuBenhao Jul 6, 2025
f531bd6
test: 3606, 3607, 3608, 3609
QuBenhao Jul 6, 2025
0e719bf
test: 3606, 3607, 3608, 3609 solution
QuBenhao Jul 6, 2025
63dfe2e
test: 3606, 3607, 3608, 3609 solution
QuBenhao Jul 6, 2025
bd7878b
test: 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609 solution
QuBenhao Jul 6, 2025
ecd0b02
fix: JavaWriter boolean[]
QuBenhao Jul 6, 2025
3694b4b
test: 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609 solution
QuBenhao Jul 6, 2025
24f2c7e
fix: java plans output
QuBenhao Jul 6, 2025
65d8f8b
test: 1640 solution
QuBenhao Jul 6, 2025
d7f50b2
docs: templates.md
QuBenhao Jul 6, 2025
e97afd4
test: codeforces contest/2119/A
QuBenhao Jul 6, 2025
4d66d31
test: [20250707] Add (1353)
actions-user Jul 6, 2025
8e2d582
test: 1353 solution
QuBenhao Jul 7, 2025
e3d8696
test: [20250708] Add (1751)
actions-user Jul 7, 2025
6034e41
test: 1751 solution
QuBenhao Jul 7, 2025
5f8bb77
test: 1235 solution
QuBenhao Jul 7, 2025
bfc06d2
test: 788 solution
QuBenhao Jul 7, 2025
4580c6b
test: 777 solution
QuBenhao Jul 8, 2025
9af072d
test: [20250709] Add (3439)
actions-user Jul 8, 2025
c32b579
test: 3439 solution
QuBenhao Jul 9, 2025
9949c58
test: 670 solution
QuBenhao Jul 9, 2025
83405d1
test: [20250710] Add (3440)
actions-user Jul 9, 2025
b9f4acd
test: 3440 solution
QuBenhao Jul 9, 2025
0d5c0fc
test: 672 solution
QuBenhao Jul 10, 2025
83f336f
test: [20250711] Add (3169)
actions-user Jul 10, 2025
5fffed5
test: 3169 solution
QuBenhao Jul 10, 2025
4560d6c
test: [20250712] Add (1900)
actions-user Jul 11, 2025
c215365
test: 667 solution
QuBenhao Jul 11, 2025
ec20135
test: 1900 solution
QuBenhao Jul 12, 2025
1dbd44d
test: 1592 solution
QuBenhao Jul 12, 2025
72e7b07
test: [20250713] Add (2410)
actions-user Jul 12, 2025
726cc52
test: 2410 solution
QuBenhao Jul 13, 2025
67e1590
feat: get problems by contest
QuBenhao Jul 13, 2025
1484369
test: 3612, 3613, 3614, 3615 solution
QuBenhao Jul 13, 2025
0e5b165
10.4.0
Jul 13, 2025
e853a05
test: [20250714] Add (1290)
actions-user Jul 13, 2025
fce22f4
test: 1290 solution
QuBenhao Jul 13, 2025
57eccfc
test: 662 solution
QuBenhao Jul 14, 2025
67ea07b
test: [20250715] Add (3136)
actions-user Jul 14, 2025
395d91f
test: 3136 solution
QuBenhao Jul 14, 2025
ce39a40
test: 1092 solution
QuBenhao Jul 15, 2025
367a219
test: [20250716] Add (3201)
actions-user Jul 15, 2025
79e6e1d
test: 3201 solution
QuBenhao Jul 15, 2025
600dc93
test: 658 solution
QuBenhao Jul 16, 2025
0cba050
test: [20250717] Add (3202)
actions-user Jul 16, 2025
403e196
test: 3202 solution
QuBenhao Jul 17, 2025
355a1e0
test: [20250718] Add (2163)
actions-user Jul 17, 2025
35e212d
test: 2163 solution
QuBenhao Jul 18, 2025
559ed9c
test: [20250719] Add (1233)
actions-user Jul 18, 2025
5298b19
test: 1233 solution
QuBenhao Jul 19, 2025
2e9f2ae
test: 1464 solution
QuBenhao Jul 19, 2025
e7e511f
test: [20250720] Add (1948)
actions-user Jul 19, 2025
d9c2e52
test: 1948 solution
QuBenhao Jul 19, 2025
d86a395
test: 3618, 3619, 3620, 3621 add
QuBenhao Jul 19, 2025
c33ca40
test: 3618, 3619, 3620, 3621 solution
QuBenhao Jul 19, 2025
4ebf868
test: 3618, 3619, 3620, 3621 solution
QuBenhao Jul 19, 2025
e62be22
test: 3618, 3619, 3620, 3621 solution
QuBenhao Jul 20, 2025
b4c9dce
test: 3618, 3619, 3620, 3621 solution
QuBenhao Jul 20, 2025
012e8a0
test: 3618, 3619, 3620, 3621 solution
QuBenhao Jul 20, 2025
5ccaeda
test: 3622, 3623, 3624, 3625 add
QuBenhao Jul 20, 2025
331c028
test: 3622, 3623, 3624, 3625 add
QuBenhao Jul 20, 2025
a879a1d
test: 3622, 3623, 3624, 3625 solution
QuBenhao Jul 20, 2025
dec03af
test: 3622, 3623, 3624, 3625 solution
QuBenhao Jul 20, 2025
478a98a
test: 3622, 3623, 3624, 3625 solution
QuBenhao Jul 20, 2025
ce23967
test: 3622, 3623, 3624, 3625 solution
QuBenhao Jul 20, 2025
a12ccc7
test: [20250721] Add (1957)
actions-user Jul 20, 2025
0e3eb70
test: 1957 solution
QuBenhao Jul 20, 2025
7fe8230
docs: template
QuBenhao Jul 20, 2025
41338f6
test: 1656 solution
QuBenhao Jul 20, 2025
e4e0252
test: 1282 solution
QuBenhao Jul 21, 2025
3436db3
test: [20250722] Add (1695)
actions-user Jul 21, 2025
c5ca206
test: 1695 solution
QuBenhao Jul 22, 2025
9e21e01
test: 1695 solution
QuBenhao Jul 22, 2025
1666cc8
test: 768 solution
QuBenhao Jul 22, 2025
af2e0de
test: [20250723] Add (1717)
actions-user Jul 22, 2025
ee2db84
test: 1717 solution
QuBenhao Jul 22, 2025
6e4575c
test: 640 solution
QuBenhao Jul 23, 2025
af102b4
test: [20250724] Add (2322)
actions-user Jul 23, 2025
31af44d
test: 2322 solution
QuBenhao Jul 23, 2025
dff47fa
test: 636 solution
QuBenhao Jul 24, 2025
41541c6
test: [20250725] Add (3487)
actions-user Jul 24, 2025
62e05dc
test: 3620 solution
QuBenhao Jul 24, 2025
f9a475f
test: 3487 solution
QuBenhao Jul 24, 2025
349fc52
test: [20250726] Add (3480)
actions-user Jul 25, 2025
00636f9
test: 3480 solution
QuBenhao Jul 26, 2025
b8c1409
test: 622 solution
QuBenhao Jul 26, 2025
6a7d255
test: 623 solution
QuBenhao Jul 26, 2025
b208011
test: [20250727] Add (2210)
actions-user Jul 26, 2025
6a11dd5
test: 2210 solution
QuBenhao Jul 26, 2025
fd36896
docs: add 质因数分解
QuBenhao Jul 27, 2025
c404113
test: 1260 solution
QuBenhao Jul 27, 2025
3e10dad
test: [20250728] Add (2044)
actions-user Jul 27, 2025
e270e7b
test: 2044 solution
QuBenhao Jul 27, 2025
d3fa321
test: 3628, 3629 solution
QuBenhao Jul 27, 2025
4fe3be5
test: 3628, 3629 solution
QuBenhao Jul 27, 2025
5e88ca6
test: 3628, 3629 solution
QuBenhao Jul 28, 2025
3af8eec
test: 3628, 3629 solution
QuBenhao Jul 28, 2025
e5a00ba
test: 741 solution
QuBenhao Jul 28, 2025
1622d95
test: [20250729] Add (2411)
actions-user Jul 28, 2025
e979e59
test: 2411 solution
QuBenhao Jul 28, 2025
4ff5d1c
test: 241 solution
QuBenhao Jul 29, 2025
58b8f41
test: [20250730] Add (2419)
actions-user Jul 29, 2025
0a5e7cc
test: 2419 solution
QuBenhao Jul 29, 2025
8bf8c55
test: 406 solution
QuBenhao Jul 30, 2025
310ff6c
test: [20250731] Add (2683)
actions-user Jul 30, 2025
8f2c050
test: 2683 solution
QuBenhao Jul 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: [20250729] Add (2411)
  • Loading branch information
actions-user committed Jul 28, 2025
commit 1622d95c69d91decd81ef1492becf4c73ae7dbdd
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ members = [
"problems/problems_3480",
"problems/problems_2210",
"problems/problems_2044",
"problems/problems_2411",
]

[package]
Expand Down Expand Up @@ -562,3 +563,4 @@ solution_3487 = { path = "problems/problems_3487", features = ["solution_3487"]
solution_3480 = { path = "problems/problems_3480", features = ["solution_3480"] }
solution_2210 = { path = "problems/problems_2210", features = ["solution_2210"] }
solution_2044 = { path = "problems/problems_2044", features = ["solution_2044"] }
solution_2411 = { path = "problems/problems_2411", features = ["solution_2411"] }
2 changes: 1 addition & 1 deletion daily-problems.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"daily": "741",
"daily": "2411",
"plans": ["3628", "problems", "3629", "problems"]
}
4 changes: 2 additions & 2 deletions golang/solution_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package golang

import (
problem "leetCode/problems/problems_741"
problem "leetCode/problems/problems_2411"
"testing"
)

func TestSolution(t *testing.T) {
TestEach(t, "741", "problems", problem.Solve)
TestEach(t, "2411", "problems", problem.Solve)
}
21 changes: 21 additions & 0 deletions problems/problems_2411/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "solution_2411"
version = "0.1.0"
edition = "2021"
rust-version = "1.79.0"
authors = ["benhao"]
description = "LeetCode Solution 2411 in Rust"
readme = "../../README.md"

[features]
solution_2411 = []

[dependencies]
serde_json = "1.0"
rand = "0.8.4"
regex = "1.10.5"
library = { path = "../../rust/library", features = ["model"] }

[lib]
name = "solution_2411"
path = "solution.rs"
28 changes: 28 additions & 0 deletions problems/problems_2411/Solution.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//go:build ignore
#include "cpp/common/Solution.h"


using namespace std;
using json = nlohmann::json;

class Solution {
public:
vector<int> smallestSubarrays(vector<int>& nums) {

}
};

json leetcode::qubh::Solve(string input_json_values) {
vector<string> inputArray;
size_t pos = input_json_values.find('\n');
while (pos != string::npos) {
inputArray.push_back(input_json_values.substr(0, pos));
input_json_values = input_json_values.substr(pos + 1);
pos = input_json_values.find('\n');
}
inputArray.push_back(input_json_values);

Solution solution;
vector<int> nums = json::parse(inputArray.at(0));
return solution.smallestSubarrays(nums);
}
18 changes: 18 additions & 0 deletions problems/problems_2411/Solution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package problems.problems_2411;

import com.alibaba.fastjson.JSON;
import java.util.*;
import qubhjava.BaseSolution;


public class Solution extends BaseSolution {
public int[] smallestSubarrays(int[] nums) {

}

@Override
public Object solve(String[] inputJsonValues) {
int[] nums = jsonArrayToIntArray(inputJsonValues[0]);
return JSON.toJSON(smallestSubarrays(nums));
}
}
49 changes: 49 additions & 0 deletions problems/problems_2411/problem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 2411. Smallest Subarrays With Maximum Bitwise OR [Rating: 1938.06]

<p>You are given a <strong>0-indexed</strong> array <code>nums</code> of length <code>n</code>, consisting of non-negative integers. For each index <code>i</code> from <code>0</code> to <code>n - 1</code>, you must determine the size of the <strong>minimum sized</strong> non-empty subarray of <code>nums</code> starting at <code>i</code> (<strong>inclusive</strong>) that has the <strong>maximum</strong> possible <strong>bitwise OR</strong>.</p>

<ul>
<li>In other words, let <code>B<sub>ij</sub></code> be the bitwise OR of the subarray <code>nums[i...j]</code>. You need to find the smallest subarray starting at <code>i</code>, such that bitwise OR of this subarray is equal to <code>max(B<sub>ik</sub>)</code> where <code>i &lt;= k &lt;= n - 1</code>.</li>
</ul>

<p>The bitwise OR of an array is the bitwise OR of all the numbers in it.</p>

<p>Return <em>an integer array </em><code>answer</code><em> of size </em><code>n</code><em> where </em><code>answer[i]</code><em> is the length of the <strong>minimum</strong> sized subarray starting at </em><code>i</code><em> with <strong>maximum</strong> bitwise OR.</em></p>

<p>A <strong>subarray</strong> is a contiguous non-empty sequence of elements within an array.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [1,0,2,1,3]
<strong>Output:</strong> [3,3,2,2,1]
<strong>Explanation:</strong>
The maximum possible bitwise OR starting at any index is 3.
- Starting at index 0, the shortest subarray that yields it is [1,0,2].
- Starting at index 1, the shortest subarray that yields the maximum bitwise OR is [0,2,1].
- Starting at index 2, the shortest subarray that yields the maximum bitwise OR is [2,1].
- Starting at index 3, the shortest subarray that yields the maximum bitwise OR is [1,3].
- Starting at index 4, the shortest subarray that yields the maximum bitwise OR is [3].
Therefore, we return [3,3,2,2,1].
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [1,2]
<strong>Output:</strong> [2,1]
<strong>Explanation:
</strong>Starting at index 0, the shortest subarray that yields the maximum bitwise OR is of length 2.
Starting at index 1, the shortest subarray that yields the maximum bitwise OR is of length 1.
Therefore, we return [2,1].
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>n == nums.length</code></li>
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
</ul>
49 changes: 49 additions & 0 deletions problems/problems_2411/problem_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 2411. 按位或最大的最小子数组长度 [难度分: 1938.06]

<p>给你一个长度为 <code>n</code>&nbsp;下标从 <strong>0</strong>&nbsp;开始的数组&nbsp;<code>nums</code>&nbsp;,数组中所有数字均为非负整数。对于&nbsp;<code>0</code>&nbsp;到&nbsp;<code>n - 1</code>&nbsp;之间的每一个下标 <code>i</code>&nbsp;,你需要找出&nbsp;<code>nums</code>&nbsp;中一个 <strong>最小</strong> 非空子数组,它的起始位置为&nbsp;<code>i</code>&nbsp;(包含这个位置),同时有&nbsp;<strong>最大</strong>&nbsp;的 <strong>按位或</strong><b>运算值</b>&nbsp;。</p>

<ul>
<li>换言之,令&nbsp;<code>B<sub>ij</sub></code>&nbsp;表示子数组&nbsp;<code>nums[i...j]</code>&nbsp;的按位或运算的结果,你需要找到一个起始位置为&nbsp;<code>i</code>&nbsp;的最小子数组,这个子数组的按位或运算的结果等于&nbsp;<code>max(B<sub>ik</sub>)</code>&nbsp;,其中&nbsp;<code>i &lt;= k &lt;= n - 1</code>&nbsp;。</li>
</ul>

<p>一个数组的按位或运算值是这个数组里所有数字按位或运算的结果。</p>

<p>请你返回一个大小为 <code>n</code>&nbsp;的整数数组<em>&nbsp;</em><code>answer</code>,其中<em>&nbsp;</em><code>answer[i]</code>是开始位置为&nbsp;<code>i</code>&nbsp;,按位或运算结果最大,且&nbsp;<strong>最短</strong>&nbsp;子数组的长度。</p>

<p><strong>子数组</strong>&nbsp;是数组里一段连续非空元素组成的序列。</p>

<p>&nbsp;</p>

<p><strong>示例 1:</strong></p>

<pre><b>输入:</b>nums = [1,0,2,1,3]
<b>输出:</b>[3,3,2,2,1]
<strong>解释:</strong>
任何位置开始,最大按位或运算的结果都是 3 。
- 下标 0 处,能得到结果 3 的最短子数组是 [1,0,2] 。
- 下标 1 处,能得到结果 3 的最短子数组是 [0,2,1] 。
- 下标 2 处,能得到结果 3 的最短子数组是 [2,1] 。
- 下标 3 处,能得到结果 3 的最短子数组是 [1,3] 。
- 下标 4 处,能得到结果 3 的最短子数组是 [3] 。
所以我们返回 [3,3,2,2,1] 。
</pre>

<p><strong>示例 2:</strong></p>

<pre><b>输入:</b>nums = [1,2]
<b>输出:</b>[2,1]
<strong>解释:
</strong>下标 0 处,能得到最大按位或运算值的最短子数组长度为 2 。
下标 1 处,能得到最大按位或运算值的最短子数组长度为 1 。
所以我们返回 [2,1] 。
</pre>

<p>&nbsp;</p>

<p><strong>提示:</strong></p>

<ul>
<li><code>n == nums.length</code></li>
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
</ul>
22 changes: 22 additions & 0 deletions problems/problems_2411/solution.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package problem2411

import (
"encoding/json"
"log"
"strings"
)

func smallestSubarrays(nums []int) []int {

}

func Solve(inputJsonValues string) any {
inputValues := strings.Split(inputJsonValues, "\n")
var nums []int

if err := json.Unmarshal([]byte(inputValues[0]), &nums); err != nil {
log.Fatal(err)
}

return smallestSubarrays(nums)
}
11 changes: 11 additions & 0 deletions problems/problems_2411/solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import solution
from typing import *


class Solution(solution.Solution):
def solve(self, test_input=None):
return self.smallestSubarrays(test_input)

def smallestSubarrays(self, nums: List[int]) -> List[int]:
pass

16 changes: 16 additions & 0 deletions problems/problems_2411/solution.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use serde_json::{json, Value};

pub struct Solution;

impl Solution {
pub fn smallest_subarrays(nums: Vec<i32>) -> Vec<i32> {

}
}

#[cfg(feature = "solution_2411")]
pub fn solve(input_string: String) -> Value {
let input_values: Vec<String> = input_string.split('\n').map(|x| x.to_string()).collect();
let nums: Vec<i32> = serde_json::from_str(&input_values[0]).expect("Failed to parse input");
json!(Solution::smallest_subarrays(nums))
}
9 changes: 9 additions & 0 deletions problems/problems_2411/solution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function smallestSubarrays(nums: number[]): number[] {

};

export function Solve(inputJsonElement: string): any {
const inputValues: string[] = inputJsonElement.split("\n");
const nums: number[] = JSON.parse(inputValues[0]);
return smallestSubarrays(nums);
}
2 changes: 2 additions & 0 deletions problems/problems_2411/testcase
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
["[1,0,2,1,3]", "[1,2]"]
[[3, 3, 2, 2, 1], [2, 1]]
14 changes: 14 additions & 0 deletions problems/problems_2411/testcase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from collections import namedtuple
import testcase

case = namedtuple("Testcase", ["Input", "Output"])


class Testcase(testcase.Testcase):
def __init__(self):
self.testcases = []
self.testcases.append(case(Input=[1, 0, 2, 1, 3], Output=[3, 3, 2, 2, 1]))
self.testcases.append(case(Input=[1, 2], Output=[2, 1]))

def get_testcases(self):
return self.testcases
4 changes: 2 additions & 2 deletions rust/test_executor/tests/solutions_test.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const PROBLEMS: [[&str; 2]; 1] = [["problems", "2044"]];
const PROBLEMS: [[&str; 2]; 1] = [["problems", "2411"]];

#[cfg(test)]
mod test {
use test_executor::run_test::run_test;
use crate::PROBLEMS;

use solution_2044 as solution;
use solution_2411 as solution;

#[test]
fn test_solutions() {
Expand Down